Skip to content

Reject incomplete OPFS transfers in the synchronous store - #66

Merged
PierreRaybaut merged 2 commits into
developfrom
fix/opfs-short-transfers
Oct 24, 2026
Merged

PierreRaybaut merged 2 commits into
developfrom
fix/opfs-short-transfers

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Summary

Follow-up of the updated review of the develop branches (R1, remainder of A02).

FileSystemSyncAccessHandle.read()/write() return the number of bytes actually transferred, which the File System standard allows to be lower than requested. OpfsSyncObjectStore ignored it:

  • a short write was truncated/extended to the payload length and reported as stored: the runtime released the object from memory while its file held partial data;
  • a short read returned a buffer partly filled with zeros, without error.

put() now writes the remaining bytes in turn and throws when a write transfers nothing, before recording the size: the existing spill rollback (persistOrRestore) then keeps the object resident. get() reads in turn and throws when the file cannot be read up to its size.

Tests

  • Store: payload written and read in several fragments; write making no progress; write failing after a first fragment; read unable to reach the end of the file (4 tests fail without the fix).
  • Runtime: an incomplete write rolls the object back to memory, like a quota error.
  • Vitest 897 passed (107 files), lint, format, i18n check, production build.

FileSystemSyncAccessHandle.read() and write() return the number of bytes
actually transferred, which the File System standard allows to be lower
than requested. OpfsSyncObjectStore ignored it: a short write was
truncated/extended to the payload length and reported as stored, so that
the runtime released the object from memory while its file held partial
data; a short read returned a buffer partly filled with zeros.

put() now writes the remaining bytes in turn and throws when a write
transfers nothing, before recording the size, so that the existing spill
rollback keeps the object resident; get() reads in turn and throws when
the file cannot be read up to its size.

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 82ce112 into develop Oct 24, 2026
9 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/opfs-short-transfers branch October 24, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant