Repository navigation
OPFSCoopSyncVFS: tolerate a temporary directory whose files are still open - #386
Merged
rhashimoto merged 1 commit intoNov 15, 2026
Conversation
2 tasks done
… open A worker that goes away without closing its access handles, such as one whose page the back/forward cache evicts, can have its directory's lock released before its handles are closed. The next instance's sweep then gets the lock, removeEntry throws NoModificationAllowedError, and create() fails. The directory is left for a later instance to delete, as it already is when another instance deleted it first (rhashimoto#347). Fixes rhashimoto#362. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Rebased on |
lalexdotcom
force-pushed
the
opfscoopsync-sweep-held-directory
branch
from
October 23, 2026 17:56
a21e9d4 to
c4f832e
Compare
Owner
|
Thanks for the PR! LGTM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the PR offered in #362:
NoModificationAllowedErroradded to the errors the sweep tolerates, with a test.What happens
When
OPFSCoopSyncVFSinitializes, it deletes every.ahp-*directory whose lock it can get. A worker that goes away without closing its access handles can have that lock released before its handles are closed. A page evicted by the back/forward cache is one example (#362). The next instance then gets the lock,removeEntry()throwsNoModificationAllowedError, andcreate()fails. OnlyNotFoundErroris tolerated there today (#347).It reproduces in Chrome and Firefox.
The change
The sweep also tolerates
NoModificationAllowedErrorand leaves the directory in place. A later instance deletes it once its files are closed, the same way the sweep already handles a directory another instance deleted first. The change is one condition, and it costs nothing on the normal path.The test
test/vfs_handover.jsgets a case next to #347's. A worker holds an access handle on a file inside an.ahp-*directory, and nobody holds that directory's lock. A new instance must start. After the handle is closed, the instance after that one must delete the directory. Onmasterthe start fails withNoModificationAllowedErrorin Chrome and Firefox, for all three builds. With the change it passes.createHolder()intest/vfs_handle_recovery.jscan now put the file in a subdirectory.Fixes #362.
Conflict with #381
#381 also changes
src/examples/OPFSCoopSyncVFS.jsandtest/vfs_handover.js. The source changes don't overlap and merge cleanly. The test file conflicts: both PRs add a case at the end of the samedescribe, and #381 changesstartInstance()to resolve to{ worker, port }instead of the worker.master: keep both cases and make this one's twostartInstance()calls use.worker.masterthe same way: keep both cases, and make this PR's case use.workeras part of OPFSCoopSyncVFS: retry access handles still held after a terminated connection #381's change tostartInstance().This PR doesn't conflict with my other open PRs (#382, #384, #385).
Checklist
non-exclusive, royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, sublicense, and distribute this
Contribution and such derivative works.
Contribution contains no content requiring a license from any third party.