Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions dist/wa-sqlite-async.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-async.wasm
Binary file not shown.
18 changes: 2 additions & 16 deletions dist/wa-sqlite-jspi.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite-jspi.wasm
Binary file not shown.
18 changes: 2 additions & 16 deletions dist/wa-sqlite.mjs

Large diffs are not rendered by default.

Binary file modified dist/wa-sqlite.wasm
Binary file not shown.
29 changes: 18 additions & 11 deletions src/examples/OPFSCoopSyncVFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,24 @@ export class OPFSCoopSyncVFS extends FacadeVFS {
this._module.retryOps.push((async () => {
// Acquire the Web Lock.
file.persistentFile.handleLockReleaser = await this.#acquireLock(file.persistentFile);

// Get access handles for the database and releated files in parallel.
this.log?.(`creating access handles for ${file.path}`)
await Promise.all(DB_RELATED_FILE_SUFFIXES.map(async suffix => {
const persistentFile = this.persistentFiles.get(file.path + suffix);
if (persistentFile) {
persistentFile.accessHandle =
await persistentFile.fileHandle.createSyncAccessHandle();
}
}));
file.persistentFile.isRequestInProgress = false;
try {
// Get access handles for the database and releated files in parallel.
this.log?.(`creating access handles for ${file.path}`)
await Promise.all(DB_RELATED_FILE_SUFFIXES.map(async suffix => {
const persistentFile = this.persistentFiles.get(file.path + suffix);
if (persistentFile) {
persistentFile.accessHandle =
await persistentFile.fileHandle.createSyncAccessHandle();
}
}));
} catch (e) {
this.log?.(`failed to create access handles for ${file.path}`, e);
// Close any of the potentially opened access handles
this.#releaseAccessHandle(file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The #releaseAccessHandle function is declared as async, meaning it returns a promise. Although it currently contains no await statements, it's a good practice to await the call. This makes the code more robust and prevents potential race conditions if the function's implementation becomes truly asynchronous in the future.

Suggested change
this.#releaseAccessHandle(file);
await this.#releaseAccessHandle(file);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this method is marked as async since it doesn't contain any await statements internally, but it's probably safer to await the call here to handle the async signature correctly.

Copy link
Owner

@rhashimoto rhashimoto Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevensJourney You're right, there's no reason for #releaseAccessHandle() to be async or contain any async code. I don't know what I was thinking there. Let's just fix that instead by:

Everything else LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me :) . I've made those changes.

throw e;
} finally {
file.persistentFile.isRequestInProgress = false;
}
})());
return this._module.retryOps.at(-1);
}
Expand Down
7 changes: 5 additions & 2 deletions src/sqlite-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,11 @@ export function Factory(Module) {
// Wait for all pending retry operations to complete. This is
// normally empty on the first loop iteration.
if (Module.retryOps.length) {
await Promise.all(Module.retryOps);
Module.retryOps = [];
try {
await Promise.all(Module.retryOps);
} finally {
Module.retryOps = [];
}
}

rc = await f();
Expand Down