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
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
Copy file name to clipboardExpand all lines: README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -13,4 +13,4 @@ This monorepo uses [melos](https://melos.invertase.dev/) to handle command and p
13
13
14
14
To configure the monorepo for development run `melos prepare` after cloning.
15
15
16
-
For detailed usage, check out the inner [sqlite_async](https://github.com/powersync-ja/sqlite_async.dart/tree/main/packages/sqlite_async) and [drift_sqlite_async](https://github.com/powersync-ja/sqlite_async.dart/tree/main/packages/drift_sqlite_async) packages.
16
+
For detailed usage, check out the inner [sqlite_async](https://github.com/powersync-ja/sqlite_async.dart/tree/main/packages/sqlite_async) and [drift_sqlite_async](https://github.com/powersync-ja/sqlite_async.dart/tree/main/packages/drift_sqlite_async) packages.
/// Passing the Dart callback directly to the JS Navigator can cause some weird
96
+
/// context related bugs. Instead the JS lock callback will return a hold on the lock
97
+
/// which is represented as a [HeldLock]. This hold can be used when wrapping the Dart
98
+
/// callback to manage the JS lock.
99
+
/// This is inspired and adapted from https://github.com/simolus3/sqlite3.dart/blob/7bdca77afd7be7159dbef70fd1ac5aa4996211a9/sqlite3_web/lib/src/locks.dart#L6
100
+
Future<HeldLock> _getWebLock(Duration? timeout) {
101
+
final gotLock =Completer<HeldLock>.sync();
102
+
// Navigator locks can be timed out by using an AbortSignal
103
+
final controller =AbortController();
104
+
105
+
Timer? timer;
106
+
107
+
if (timeout !=null) {
108
+
timer =Timer(timeout, () {
109
+
gotLock
110
+
.completeError(TimeoutException('Failed to acquire lock', timeout));
111
+
controller.abort('Timeout'.toJS);
112
+
});
113
+
}
114
+
115
+
// If timeout occurred before the lock is available, then this callback should not be called.
116
+
JSPromisejsCallback(JSAny lock) {
117
+
timer?.cancel();
118
+
119
+
// Give the Held lock something to mark this Navigator lock as completed
0 commit comments