Repository navigation
fix: [SDK-5377] close IndexedDB on versionchange and open newer versions - #1575
Open
fadi-george wants to merge 3 commits into
Open
fadi-george wants to merge 3 commits into
fadi-george wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e handling Co-Authored-By: Claude Opus 5.5 <[email protected]>
fadi-george
force-pushed
the
fadi/sdk-5377-idb-versionchange
branch
from
November 13, 2026 00:21
fbcb571 to
f38f021
Compare
…lback Co-Authored-By: Claude Opus 5.5 <[email protected]>
nan-li
approved these changes
Nov 13, 2026
Contributor
|
Can we hold off on merging this until after IV is released? |
13 of 16 tasks
sherwinski
requested changes
Nov 13, 2026
sherwinski
left a comment
Contributor
There was a problem hiding this comment.
Holding until IV release
sherwinski
reviewed
Nov 13, 2026
sherwinski
left a comment
Contributor
There was a problem hiding this comment.
- Non-blocking: src/shared/database/client.ts:136, if
dbWedgedis alreadytrue, aversionchangereopen leavesdbPromisepending anddb.*hangs beforeguard()checksdbWedged. Let's check fordbWedgedbefore awaitingdbPromise. - Non-blocking: src/shared/database/client.ts:87,
void getDb()has no catch, so a failed reopen on an idle tab or SW gives an unhandled rejection. Consider adding acatchwith a debug log. - Non-blocking: src/shared/database/idb-lite.ts:60,
versionchangealso fires fordeleteDatabase(wherenewVersion == null). Then, thereopenrecreates the DB and sets_isNewVisitor. Consider skippiing the reopen whennewVersionisnull.
sherwinski
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
1 Line Summary
Close IndexedDB connections on
versionchange, open a DB a newer SDK already upgraded, and only flag new visitors when the DB is created.Details
Found while reviewing #1571, which bumps the DB to v8.
versionchange, so a tab or worker on an older SDK held its connection open and a newer SDK's upgrade stayed blocked.blocked()only logs and the op timeout guard does not cover open, soinit()and SW DB calls hung until the old tab closed. Connections now close onversionchangeand reopen.VERSIONhitVersionErrorand every DB op failed (rollbacks, mixed tabs). It now reopens the DB at its current version.upgrade()setOneSignal._isNewVisitoron every upgrade, so a version bump showed the bell prenotify badge to returning unsubscribed visitors. Now only whenoldVersion === 0.OneSignalSDK.page.es6.jsto 47.12 kB andOneSignalSDK.sw.jsto 13.68 kB.Limitation: tabs on the currently released SDK do not have the handler and still block an upgrade. This needs to ship in a release before the v8 bump in #1571 to protect that transition.
Systems Affected
Validation
Tests
Info
New tests: a newer version can upgrade while a connection is open, opening a DB a newer version already upgraded, and
_isNewVisitornot set on upgrade. All three fail without the fix.vp checkclean (only existing warnings), fullvp run testpasses (1035),vp run build:prodpasses.Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemap.contextif possible.Screenshots
Info
No UI changes.
Checklist
Related Tickets
SDK-5377
🤖 Generated with Claude Code