Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/fluffy-plums-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@journeyapps/wa-sqlite': patch
---

Fix potential deadlocks and Failed to execute 'createSyncAccessHandle' on 'FileSystemFileHandle' errors.
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);
throw e;
} finally {
file.persistentFile.isRequestInProgress = false;
}
})());
return this._module.retryOps.at(-1);
}
Expand Down