[feedback] text-tools: Unchecked runtime.lastError: Cannot create item with duplicate id text #4

Open
opened 2026-11-19 18:31:01 +01:00 by monyi · 1 comment
Owner

Feedback #35 · 2026-11-19 16:39:17 · ext: text-tools · reason: bugs

Unchecked runtime.lastError: Cannot create item with duplicate id text-tools-parent
Contexto
Desconocido
Seguimiento de la pila
:0 (función anónima)


Origen: https://greasysprocket.com/feedback · repo destino: extensión
Creado por el triaje automático (gs-feedback-triage.py).

**Feedback #35** · 2026-11-19 16:39:17 · ext: `text-tools` · reason: `bugs` > Unchecked runtime.lastError: Cannot create item with duplicate id text-tools-parent > Contexto > Desconocido > Seguimiento de la pila > :0 (función anónima) --- Origen: https://greasysprocket.com/feedback · repo destino: `extensión` Creado por el triaje automático (`gs-feedback-triage.py`).
Author
Owner

Diagnóstico

setupContextMenus() está enganchado a onInstalled y a onStartup sin guard de reentrada: si ambos disparan solapados, el removeAll de la segunda cadena borra los ids que la primera acaba de crear, y el create({id: "text-tools-parent"}) posterior choca con el de la otra cadena. Como el callback no lee chrome.runtime.lastError, Chrome lo reporta como Unchecked runtime.lastError: Cannot create item with duplicate id.

Ficheros

  • src/entrypoints/background.ts:16 — PARENT_ID = "text-tools-parent"
  • src/entrypoints/background.ts:38-56 — removeAll + create sin comprobar lastError
  • src/entrypoints/background.ts:58 (onInstalled) y :81 (onStartup) — dos disparadores del mismo setup

Plan (bug)

  1. Guard de reentrada menuCreating / menuPending con bucle do…while alrededor del setup, como en copycat/src/entrypoints/background.ts:35-105.
  2. Helper createMenu() que en el callback lea chrome.runtime.lastError y trate duplicate id como no-op (browser.contextMenus.create del polyfill no lanza: deja el error ahí y se ve como "Unchecked").
  3. Test en tests/ con un fake de chrome.contextMenus que llame al setup dos veces seguidas y exija 0 errores.
**Diagnóstico** `setupContextMenus()` está enganchado a `onInstalled` y a `onStartup` sin guard de reentrada: si ambos disparan solapados, el `removeAll` de la segunda cadena borra los ids que la primera acaba de crear, y el `create({id: "text-tools-parent"})` posterior choca con el de la otra cadena. Como el callback no lee `chrome.runtime.lastError`, Chrome lo reporta como `Unchecked runtime.lastError: Cannot create item with duplicate id`. **Ficheros** - `src/entrypoints/background.ts:16` — `PARENT_ID = "text-tools-parent"` - `src/entrypoints/background.ts:38-56` — `removeAll` + `create` sin comprobar `lastError` - `src/entrypoints/background.ts:58` (`onInstalled`) y `:81` (`onStartup`) — dos disparadores del mismo setup **Plan (bug)** 1. Guard de reentrada `menuCreating` / `menuPending` con bucle `do…while` alrededor del setup, como en `copycat/src/entrypoints/background.ts:35-105`. 2. Helper `createMenu()` que en el callback lea `chrome.runtime.lastError` y trate `duplicate id` como no-op (`browser.contextMenus.create` del polyfill no lanza: deja el error ahí y se ve como "Unchecked"). 3. Test en `tests/` con un fake de `chrome.contextMenus` que llame al setup dos veces seguidas y exija 0 errores.
Sign in to join this conversation.
No labels
bug
feedback
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
monyi/text-tools#4
No description provided.