Skip to content

Commit 70c3b0a

Browse files
committed
Fix compilation warnings
1 parent 150a4da commit 70c3b0a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

packages/web/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class WASQLiteDBAdapter extends LockedAsyncDatabaseAdapter {
5454
const remote = Comlink.wrap<OpenAsyncDatabaseConnection>(workerPort);
5555
return new WorkerWrappedAsyncDatabaseConnection({
5656
remote,
57+
remoteCanCloseUnexpectedly: false,
5758
identifier: options.dbFilename,
5859
baseConnection: await remote({
5960
...options,

packages/web/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ export class WASQLiteOpenFactory extends AbstractWebSQLOpenFactory {
8282

8383
return new WorkerWrappedAsyncDatabaseConnection({
8484
remote: workerDBOpener,
85+
// This tab owns the worker, so we're guaranteed to outlive it.
86+
remoteCanCloseUnexpectedly: false,
8587
baseConnection: await workerDBOpener({
8688
dbFilename: this.options.dbFilename,
8789
vfs,

packages/web/src/worker/sync/SharedSyncImplementation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,13 @@ export class SharedSyncImplementation extends BaseObserver<SharedSyncImplementat
481481
const wrapped = new WorkerWrappedAsyncDatabaseConnection({
482482
remote,
483483
baseConnection: db,
484-
identifier
484+
identifier,
485+
// It's possible for this worker to outlive the client hosting the database for us. We need to be prepared for
486+
// that and ensure pending requests are aborted when the tab is closed.
487+
remoteCanCloseUnexpectedly: true
485488
});
486489
lastClient.closeListeners.push(() => {
490+
this.logger.info('Aborting open connection because associated tab closed.');
487491
wrapped.markRemoteClosed();
488492
});
489493

0 commit comments

Comments
 (0)