Eagerly create multi-entry/fulltext index object stores in transaction constructor#84
Open
jell0wed wants to merge 3 commits intomicrosoft:masterfrom
Open
Conversation
added 2 commits
April 28, 2026 13:58
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.
Problem
IndexedDbProvider.openTransaction()creates the IDB transaction inside a.then()callback. When_fakeComplicatedKeysistrue, multi-entry and full-text indexes are emulated as separate physical IDB object stores (e.g.replyChains_byMessageSearchKeys,dbVersion_dbName). These extra stores must be included in the IDB transaction scope — andopenTransaction()does include them in thedb.transaction()call — but the constructor ofIndexedDbTransactiononly captures references to the primary stores. The index stores are captured lazily, insidegetStore().This creates a timing bug:
An IDB transaction is only "active" for the duration of the task or microtask in which it was created (or in which one of its request events fired). By the time
getStore()is called in M2, the transaction has gone inactive andobjectStore()throwsInvalidStateError.Even without any actual IDB requests being issued, the transaction can auto-commit once it goes inactive and the current event task completes with no pending requests — leaving it in a "done" state that also makes any subsequent
objectStore()call throw.Solution
Eagerly capture multi-entry/full-text index object stores in the
IndexedDbTransactionconstructor, in the same microtask (M1) as thedb.transaction()call — while the transaction is guaranteed to still be "active".getStore()is updated to look up from this map rather than callingthis._trans.objectStore()lazily.