Repository navigation
OPFSAdaptiveVFS: load where FileSystemSyncAccessHandle is unavailable - #374
Open
lalexdotcom wants to merge 2 commits into
Open
lalexdotcom wants to merge 2 commits into
lalexdotcom wants to merge 2 commits into
Conversation
The module read FileSystemSyncAccessHandle.prototype while it was evaluated, so importing it threw wherever the interface is missing: on a main thread, in Node, on a page that is not a secure context, and in browsers older than the interface. A worker bundling several VFS then failed to load as a whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What happens
OPFSAdaptiveVFS.jsreadsglobalThis.FileSystemSyncAccessHandle.prototypewhile the module is evaluated, to detectreadwrite-unsafesupport. Where the interface does not exist, importing the module throws aTypeErrorbefore anything else runs. That is the case:localhostaside), where browsers withhold OPFS;The VFS cannot run there anyway, but importing it should not fail. For example, an application bundles several VFS into one worker and picks one at runtime. Where this interface is missing, it cannot use
MemoryVFSor an IndexedDB VFS either, because the whole worker fails to load.The change
Optional chaining on that read:
hasUnsafeAccessHandleisundefinedwhere the interface is missing. Where it exists, nothing changes.Test
test/OPFSAdaptiveVFS.test.jsgains a test that imports the module from the test page, a main thread, whereFileSystemSyncAccessHandleis undefined. Onmasterit fails on Chromium and Firefox (Playwright), for exampleExpected 'can't access property "prototype", globalThis.FileSystemSyncAccessHandle is undefined' to be undefined.With the change, the file's 72 tests pass, 3 runs of 3, on both. The whole suite passes on Chromium: 6158 passed, 0 failed.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.