Skip to content

Commit 4223302

Browse files
committed
Unsafe concurrency.
1 parent 53248e8 commit 4223302

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/wa-sqlite-driver/src/OPFSCoopSyncVFS2.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
142142
// Populate temporary directory.
143143
for (let i = 0; i < nTemporaryFiles; i++) {
144144
const tmpFile = await tmpDir.getFileHandle(`${i}.tmp`, { create: true });
145-
const tmpAccessHandle = await (tmpFile as any).createSyncAccessHandle();
145+
const tmpAccessHandle = await (tmpFile as any).createSyncAccessHandle({
146+
mode: 'readwrite-unsafe'
147+
});
146148
this.unboundAccessHandles.add(tmpAccessHandle);
147149
}
148150
}
@@ -541,7 +543,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
541543
if (subPersistentFile) {
542544
subPersistentFile.accessHandle = await (
543545
subPersistentFile.fileHandle as any
544-
).createSyncAccessHandle();
546+
).createSyncAccessHandle({ mode: 'readwrite-unsafe' });
545547
}
546548
})
547549
);
@@ -582,7 +584,7 @@ export class OPFSCoopSyncVFS2 extends FacadeVFS {
582584
setTimeout(notify);
583585

584586
this.log?.(`lock requested: ${lockName}`);
585-
navigator.locks.request(lockName, (lock) => {
587+
navigator.locks.request(lockName, { mode: 'shared' }, (lock) => {
586588
// We have the lock. Stop asking other connections for it.
587589
this.log?.(`lock acquired: ${lockName}`, lock);
588590
clearInterval(notifyId);

0 commit comments

Comments
 (0)