Skip to content

Commit 445ec69

Browse files
add a finalization registry entry to release access handles
1 parent a1fd0bb commit 445ec69

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/web/src/worker/db/opfs.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ export class OPFSCoopSyncVFS extends FacadeVFS {
9292
});
9393
});
9494
});
95+
96+
finalizationRegistry.register(this, async () => {
97+
for (const file of this.persistentFiles.values()) {
98+
const release = this.#releaseAccessHandle(file);
99+
try {
100+
await this.#releaseAccessHandle(file);
101+
} catch (e) {
102+
this.log?.('error releasing access handle', e);
103+
} finally {
104+
release();
105+
}
106+
}
107+
});
95108
finalizationRegistry.register(this, this.releaser);
96109
const tmpDir = await root.getDirectoryHandle(tmpDirName, { create: true });
97110

0 commit comments

Comments
 (0)