IDBFactory does not notice worker global shutdown which can result in empty IDB databases created without letting the upgradeneeded event run
Categories
(Core :: Storage: IndexedDB, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox124 | --- | fixed |
People
(Reporter: asuth, Assigned: asuth)
References
Details
Attachments
(1 file)
As observed in https://bugzilla.mozilla.org/show_bug.cgi?id=1877619#c2, correct handling of situations where the global is shutting down while an openDatabase call is in flight require us to notice when the global is being torn down. Unfortunately, we only have logic in place for this on windows, not workers. This can result in IDB in the parent process thinking the database has been successfully populated despite nothing happening in the version change transaction because the upgradeneeded event never actually was triggered in content code. Excerpting the details about the specific problem from that comment:
That we try and move forward with the version change transaction on workers is somewhat surprising because we intend to handle this through the call to !EnsureDOMObject(). In particular, we would hope the !factory.GetParentObject() check would detect this. But IDBFactory is not a DOMEventTargetHelper subclass; it only clears mGlobal in IDBFactory::DisconnectFromGlobal but this is only called from nsGlobalWindowInner and never on workers. The good news is that :saschanaz introduced GlobalTeardownObserver for cases like this, and we can use that to replace the window-specific logic IDBFactory::DisconnectFromGlobal.
Assignee | ||
Updated•1 year ago
|
Comment 1•1 year ago
|
||
Maybe it would require less refactoring if you added:
if (mIndexedDB) {
mIndexedDB->DisconnectFromGlobal(this);
mIndexedDB = nullptr;
}
to WorkerGlobalScope::NoteShuttingDown
Assignee | ||
Comment 2•1 year ago
|
||
(Bug 1653276 fixed this for windows, but not workers.)
(In reply to Jan Varga [:janv] from comment #1)
Maybe it would require less refactoring if you added:
I already have a working fix using GlobalTeardownObserver which isn't too large and does simplify some things. Also it's arguably nicer/cleaner! Looking at how easy it is to add a test. (test_abort_on_reload.html is what bug 1653276 added.)
Assignee | ||
Comment 3•1 year ago
|
||
Updated•1 year ago
|
Description
•