Skip to content

opfs-worker ignores the byte count FileSystemSyncAccessHandle.write() returns, so a short write corrupts the file silently #138

Closed

Description

@Nawid3333

Severity: low

Where: chrome/player/network/opfs-worker.mjs (setFile, saveAppend, the heartbeat write)

What happens

accessHandle.write(data, {at: 0});
...
stream.handle.write(data, {at: stream.offset});
stream.offset += data.byteLength;

FileSystemSyncAccessHandle.write() returns the number of bytes written. Nothing compares it with data.byteLength.

Failure scenario

A partial write (disk nearly full) leaves a hole; the next saveAppend lands at the assumed offset and the saved MP4 is corrupt with no error.

Suggested fix

const n = handle.write(...); if (n !== data.byteLength) throw new Error(...) in all three places.

Confidence: medium (depends on Gecko returning a short count rather than throwing).


From a line-by-line code review of the tree at 41363fd (2026-10-02). Each claim above was checked against the source before filing; the reproduction steps and line references are as of that commit.


Generated by Claude Code

Activity

  1. added
    bugSomething isn't working
    code-reviewFound by the 2026-10-02 line-by-line review
    on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-reviewFound by the 2026-10-02 line-by-line review

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions