[Web] Add support for OPFS synchronous access handles and committed records#19673
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces synchronous OPFS access mode support in OPFSStore and ArtifactOPFSCache for dedicated worker contexts, allowing for faster read and write operations. The feedback identifies a critical memory regression in async mode where files are loaded entirely into memory as ArrayBuffers instead of using lazy Blobs, which could cause OOM crashes. Additionally, the reviewer suggests adding a try-catch fallback for concurrent createSyncAccessHandle calls to prevent lock failures, and wrapping ArrayBuffers in Uint8Arrays to maintain compatibility with older browser implementations of the OPFS API.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces synchronous OPFS (Origin Private File System) access capabilities to OPFSStore and ArtifactOPFSCache via a new OPFSAccessMode option, allowing for synchronous reads and writes in supported dedicated worker contexts. It also adds support for reading cached data directly as an ArrayBuffer. The review feedback highlights two robustness issues in OPFSStore: first, a potential cache corruption scenario where a failed payload overwrite leaves an outdated metadata file intact, which can be mitigated by deleting the metadata file before writing the payload; second, a potential crash during cache reads if the metadata file is corrupted, which should be handled gracefully with a try-catch block to treat it as a cache miss.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces synchronous access mode support (OPFSAccessMode) to the Origin Private File System (OPFS) artifact cache, allowing the use of synchronous access handles in dedicated worker contexts for improved performance. The review feedback highlights several critical improvement opportunities in opfs_store.ts. Specifically, the reviewer recommends aborting writable streams on error in writePayloadWithWritable and writeRecord to prevent persistent file locks, using a sync access handle's getSize() in hasExpectedPayloadSize to avoid the overhead of creating large Blob objects, and returning a lazy Blob instead of an eager ArrayBuffer in read to mitigate memory pressure.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Add support for synchronous access handles in OPFS (https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle). Sync mode uses FileSystemSyncAccessHandle where available. Replace optional metadata with committed OPFS records written after payload. Records store the URL, payload byte count, and content type. This allows interrupted or partial writes to be treated as cache misses. Stale OPFS directory handles are cleared on
InvalidStateError.