79767440

Date: 2025-09-17 14:15:38
Score: 1
Natty:
Report link

Per @woxxom:

The service worker dies by design after a period of inactivity. To notify the browser of the chrome API listeners that will wake it up, they must be added at the initial evaluation of the script, not inside asynchronous or dynamic code. For simplicity you can do at the beginning/end of the script in the global scope e.g. omniboxHandler.addListener()

The extension is installed just once, but the script runs each time it wakes up, which is why the listeners must be always registered immediately.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @woxxom
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: JasonBodnar