Skip to content

Commit 02da810

Browse files
committed
Warn when locks are held long
1 parent f2d668f commit 02da810

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/sqlite_async/lib/src/web/web_mutex.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,17 @@ class MutexImpl implements Mutex {
114114
JSPromise jsCallback(JSAny lock) {
115115
timer?.cancel();
116116

117+
final trace = StackTrace.current;
118+
final heldSuspiciouslyLongTimer = Timer(const Duration(seconds: 10), () {
119+
print('Warning: Database lock held for 10s: $trace');
120+
});
121+
117122
// Give the Held lock something to mark this Navigator lock as completed
118123
final jsCompleter = Completer.sync();
119124
gotLock.complete(HeldLock._(jsCompleter));
120-
return jsCompleter.future.toJS;
125+
return jsCompleter.future
126+
.whenComplete(heldSuspiciouslyLongTimer.cancel)
127+
.toJS;
121128
}
122129

123130
final lockOptions = JSObject();

0 commit comments

Comments
 (0)