Closed
Description
Discussed in #33
Originally posted by szk2s March 20, 2024
Hi there. Thanks for the great library. I'm using this library in my project.
Do you have any suggestions for addressing this ClosedException issue? It appears to occur when the close
method of SqliteDatabase
is invoked. In my code, I ensure the close method is called only once, leading me to believe the database isn't already closed at the time of this method call.
I’ve not been able to make a minimum reproducible example yet.
[2024-03-20T16:14:08.240792] Instance of 'ClosedException'
#0 ParentPortClient.post (package:sqlite_async/src/port_channel.dart:77:7)
#1 _TransactionContext.close (package:sqlite_async/src/sqlite_connection_impl.dart:230:21)
#2 SqliteConnectionImpl.readLock.<anonymous closure> (package:sqlite_async/src/sqlite_connection_impl.dart:118:19)
<asynchronous suspension>
#3 SimpleMutex.lock.<anonymous closure> (package:sqlite_async/src/mutex.dart:71:16)
<asynchronous suspension>
#4 SqliteConnectionPool.readLock.<anonymous closure>.<anonymous closure> (package:sqlite_async/src/connection_pool.dart:75:18)
<asynchronous suspension>
#5 new Stream.fromFutures.onValue (dart:async/stream.dart:300:5)
<asynchronous suspension>
[2024-03-20T16:14:08.292781] Instance of 'ClosedException'
#0 ParentPortClient.post (package:sqlite_async/src/port_channel.dart:77:7)
#1 _TransactionContext.close (package:sqlite_async/src/sqlite_connection_impl.dart:230:21)
#2 SqliteConnectionImpl.readLock.<anonymous closure> (package:sqlite_async/src/sqlite_connection_impl.dart:118:19)
<asynchronous suspension>
#3 SimpleMutex.lock.<anonymous closure> (package:sqlite_async/src/mutex.dart:71:16)
<asynchronous suspension>
#4 SqliteConnectionPool.readLock.<anonymous closure>.<anonymous closure> (package:sqlite_async/src/connection_pool.dart:75:18)
<asynchronous suspension>
#5 new Stream.fromFutures.onValue (dart:async/stream.dart:300:5)
<asynchronous suspension>
Concurrent modification during iteration: Instance(length:1) of '_GrowableList'.
dart:_internal ListIterator.moveNext
package:sqlite_async/src/connection_pool.dart 186:28 SqliteConnectionPool.close
===== asynchronous gap ===========================
dart:async _CustomZone.registerBinaryCallback
test/utils.dart 89:9
If I add the following line before the close
method call, I can avoid these errors.
await Future<void>.delayed(Duration(milliseconds: 1000));
But this seems to be a flaky workaround, and I'm looking for a more reliable fix.
I appreciate any help. Thanks.
Metadata
Metadata
Assignees
Labels
No labels