A site allowed without Remember is disconnected when the background worker idles #526

Closed
opened 2026-10-14 04:49:38 +02:00 by clawbot · 1 comment
Collaborator

Where. connectedSites in src/background/index.js:59-64, a module-level object. It is the only record of a site connection allowed without "Remember my choice for this site".

What happens. README Background scheduling says it: Chrome stops the background worker after about 30 seconds idle, and module-level variables do not survive. So a connection allowed without "Remember" lasts until the first idle spell. After that eth_accounts answers [], a transaction or signature request is refused with 4100 Unauthorized, and Settings no longer lists the site under Connected Sites. The site is not sent accountsChanged, so it still shows itself connected until its next request fails. Firefox keeps its background page alive and is not affected.

Should. README Settings describes Connected Sites as the sites allowed without "Remember" "that are still connected": such a connection ends when the user removes it, switches address, or removes the address, not when the worker idles. EIP-1193: a provider emits accountsChanged whenever what eth_accounts returns changes.

Severity: minor

Definition of done

  • A connection allowed without "Remember" survives the background worker being stopped and started again, and still ends on every path that ends it today.
  • A test approves a connection without "Remember", loads the background module afresh, and finds the site still connected.

Model: opus-5-5

**Where.** `connectedSites` in `src/background/index.js:59-64`, a module-level object. It is the only record of a site connection allowed without "Remember my choice for this site". **What happens.** README Background scheduling says it: Chrome stops the background worker after about 30 seconds idle, and module-level variables do not survive. So a connection allowed without "Remember" lasts until the first idle spell. After that `eth_accounts` answers `[]`, a transaction or signature request is refused with 4100 Unauthorized, and Settings no longer lists the site under Connected Sites. The site is not sent `accountsChanged`, so it still shows itself connected until its next request fails. Firefox keeps its background page alive and is not affected. **Should.** README Settings describes Connected Sites as the sites allowed without "Remember" "that are still connected": such a connection ends when the user removes it, switches address, or removes the address, not when the worker idles. EIP-1193: a provider emits `accountsChanged` whenever what `eth_accounts` returns changes. Severity: minor ## Definition of done - [ ] A connection allowed without "Remember" survives the background worker being stopped and started again, and still ends on every path that ends it today. - [ ] A test approves a connection without "Remember", loads the background module afresh, and finds the site still connected. Model: opus-5-5
clawbot self-assigned this 2026-10-14 04:49:38 +02:00
Author
Collaborator

Plan: a connection allowed without "Remember" is kept in the browser's session storage (storage.session), which outlives the background worker being stopped and started but not a browser restart, so such a connection still lasts only for the browser session, as "without Remember" says. The module-level connectedSites object in src/background/index.js goes; every place that reads, adds or deletes an entry reads and writes session storage instead, through small wrappers added to src/shared/browserApi.js beside storageGet()/storageSet()/storageRemove(), which is where the code's access to browser storage lives. The paths that end a connection today (removal in Settings, address switch, address removal, wallet removal) end it the same way. If the Firefox manifest's minimum version predates storage.session, the PR says so in one line and raises the minimum rather than adding a second code path. Tests, in a new tests/connectedSitesWorkerRestart.test.js: approve a connection without "Remember", load the background module afresh with the same session storage, and find the site still connected (eth_accounts answers the address, Settings lists it); each path that ends a connection still ends it.

Model: opus-5-5

Plan: a connection allowed without "Remember" is kept in the browser's session storage (`storage.session`), which outlives the background worker being stopped and started but not a browser restart, so such a connection still lasts only for the browser session, as "without Remember" says. The module-level `connectedSites` object in `src/background/index.js` goes; every place that reads, adds or deletes an entry reads and writes session storage instead, through small wrappers added to `src/shared/browserApi.js` beside `storageGet()`/`storageSet()`/`storageRemove()`, which is where the code's access to browser storage lives. The paths that end a connection today (removal in Settings, address switch, address removal, wallet removal) end it the same way. If the Firefox manifest's minimum version predates `storage.session`, the PR says so in one line and raises the minimum rather than adding a second code path. Tests, in a new `tests/connectedSitesWorkerRestart.test.js`: approve a connection without "Remember", load the background module afresh with the same session storage, and find the site still connected (`eth_accounts` answers the address, Settings lists it); each path that ends a connection still ends it. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#526