Replies: 3 comments 2 replies
-
|
It's possible that
Drift initializes databases lazily on first access - can you try running e.g. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @simolus3
I refactored the code to use a singleton to ensure the connection is closed Interestingly, the error is thrown only after the first call
I don’t think await connection.runCustom('SELECT 1;');…but it throws: I can initialize the database and close it manually to emulate “first access” . final DatabaseConnection tmpConnection = await info.open(
drift_wasm.WasmStorageImplementation.sharedIndexedDb,
databaseName,
initializeDatabase: () async {
return bytes;
},
);
// failed
// RethrownDartError: LateInitializationError: Field '' has not been initialized.
// await tmpConnection.runCustom('SELECT 1;');
// work
// random test query
final tabDb = TabDbSingleton().db;
await tabDb.getAllDistinctTags().get();
await TabDbSingleton.release();
//
await tmpConnection.close();
|
Beta Was this translation helpful? Give feedback.
-
|
I found that this also happens if I call exportDatabase before import. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I ran into a problem when trying to delete and re-import a database in my web app.
I found #3460, but even with only one browser tab open,
I still hit the same error at this line:
InvalidStateError: Failed to read the 'error' property from 'IDBRequest': The request has not finished.https://github.com/vHrqO/matcha/blob/8b07a2b3a0487d76cef38d1c939601a0efecc36b/matcha/lib/services/database_file/web.dart#L68
Also, when I use
initializeDatabaseinWasmProbeResult.open(), I close the previous connection once the import completes. However, if I callclose(), the newly imported database fails to import successfully.https://github.com/vHrqO/matcha/blob/8b07a2b3a0487d76cef38d1c939601a0efecc36b/matcha/lib/services/database_file/web.dart#L72
I’m wondering:
deleteDatabaseearlier throw an error that prevents the import?Any ideas on how to properly delete and re-import the database on the web would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions