You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running an app on Web on multiple tabs, calling WasmProbeResult.deleteDatabase() never completes. If this is called with a single tab, then it completes properly.
The exception is thrown:
InvalidStateError: Failed to read the 'error' property from 'IDBRequest': The request has not finished.
package:drift/src/web/wasm_setup/shared.dart 440:31 <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 598:37 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39 dcall
package:web/src/helpers/events/streams.dart 165:63 <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 224:27 _callDartFunctionFast1
It attempts to complete the request with error (which is not set) when it receives a blocked event for IDBVersionChangeEvent. Even then the blocked event does not complete with an error, the success event never arrives.
Trying to call WasmProbeResult.deleteDatabase() to delete it when database corruption is detected, but once there are multiple tabs open, the database recovery (i.e. detect database corruption, delete it and recreate it) gets stuck.
The text was updated successfully, but these errors were encountered:
I can reproduce the issue, but I'm not sure what the right behavior would be here. As you said, ignoring the blocked event when deleting databases causes the future to never complete.
So, what do we do about this? We can make other tabs close their databases when they detect a tab trying to delete a database. The consequence is that other tabs would then report database errors until they too try to re-open their database.
So it seems to me that deleting an IndexedDB database requires some application-level support (the other tabs need to be made aware of this somehow, and drift provides no mechanism to inform users that the database has been closed without them doing anything).
Ideally I should just figure out the corruption issue, making these workarounds unnecessary.
This way the tab triggering the database deletion (or database migration) gets notified in onBlocked that other database connection are blocking and the other tabs get notified in onVersionChange that something is happening that might require a page reload (or some other action like programatically reloading the page).
These 2 hooks are probably only relevant for the IndexedDB, but that can be made clear in the docs. Not sure how the in-memory or OPFS implementation handle database deletion/migration...
When running an app on Web on multiple tabs, calling
WasmProbeResult.deleteDatabase()
never completes. If this is called with a single tab, then it completes properly.The exception is thrown:
It attempts to complete the request with
error
(which is not set) when it receives a blocked event forIDBVersionChangeEvent
. Even then the blocked event does not complete with an error, the success event never arrives.Trying to call
WasmProbeResult.deleteDatabase()
to delete it when database corruption is detected, but once there are multiple tabs open, the database recovery (i.e. detect database corruption, delete it and recreate it) gets stuck.The text was updated successfully, but these errors were encountered: