Skip to content

Fix concurrency bugs in unclose MV3 migration#25

Merged
wh5a merged 3 commits into
copilot/modernize-unclose-extensionfrom
copilot/sub-pr-24
May 12, 2026
Merged

Fix concurrency bugs in unclose MV3 migration#25
wh5a merged 3 commits into
copilot/modernize-unclose-extensionfrom
copilot/sub-pr-24

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Copilot AI changed the title [WIP] [WIP] Address feedback on modernizing unclose for Chrome extension APIs Fix concurrency bugs in unclose MV3 migration May 12, 2026
Copilot AI requested a review from wh5a May 12, 2026 09:15
Copilot finished work on behalf of wh5a May 12, 2026 09:15
@wh5a wh5a requested a review from Copilot May 12, 2026 16:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses MV3-related concurrency and lifecycle hazards in the “unclose” extension by reducing races around chrome.storage.session counters and preventing unintended history loss across extension updates.

Changes:

  • Serialized background chrome.storage.session mutations behind a promise queue to avoid closeCount/actualCount races during rapid tab events.
  • Adjusted initialization logic to avoid wiping session history on extension updates (wipe only on fresh install) and simplified startup initialization.
  • Reduced actualCount decrement race in the popup by re-reading the counter immediately before writing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
unclose/bg.js Adds a serialized write queue and updates tab event handlers to avoid concurrent counter clobbering; also stores titles even when URL hasn’t been recorded yet.
unclose/init.js Gates deep-clear initialization to installs only and avoids unnecessary clear on browser startup.
unclose/popup.js Re-reads actualCount immediately before decrementing to reduce stale-read writeback races.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread unclose/bg.js Outdated
Comment on lines +10 to +12
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
enqueueWrite(async () => {
await ensureInitialized();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 360c75c. Both onUpdated and onRemoved listeners are now async and await enqueueWrite(...), so the service worker's promise chain is kept alive until each queued write finishes.

Copilot finished work on behalf of wh5a May 12, 2026 16:32
@wh5a wh5a marked this pull request as ready for review May 12, 2026 21:29
@wh5a wh5a merged commit 6182cc5 into copilot/modernize-unclose-extension May 12, 2026
@wh5a wh5a deleted the copilot/sub-pr-24 branch May 12, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants