Skip to content

A save's OPFS session is torn down on a fixed 120 s timer; a sibling prune can then delete the file under an in-flight or reused download #134

Closed

Description

@Nawid3333

Severity: medium

Where: chrome/player/modules/StreamSaver.mjs (after Utils.revokeWhenDownloaded(url, download)), chrome/player/modules/dash2mp4/mp4merger.mjs (destroy), chrome/player/modules/remux/remuxer.mjs, chrome/player/modules/hls2mp4/hls2mp4.mjs, chrome/player/network/opfs-worker.mjs (destroy keeps the directory, prune)

What happens

Utils.revokeWhenDownloaded(url, download);
setTimeout(() => {
  blobManager.close();
}, 120000);

close() stops the worker's heartbeat and deliberately leaves the session directory. prune() in any later init() (a player opening in another tab, the next save's own new FSBlob(), a merger) removes a directory whose heartbeat is older than 10 s. The result File (getSavedFile) and, on the non-OPFS merger paths, the getBlob(id) Files inside the returned Blob, are all backed by that directory. SaveManager keeps this.downloadURL for re-use.

Failure scenario

Save a 4 GB MP4 to a slow USB stick (Firefox copies a blob at tens of MB/s, so more than three minutes). At 120 s the worker closes; a player opening in another tab at 130 s prunes the session; the download is interrupted with no message. The same for a second click on Save for the same source after two minutes once any other FSBlob has initialised: the reused URL points at deleted files.

Suggested fix

Close the blob manager from the completion path revokeWhenDownloaded already tracks (give it a callback, or return a promise that settles when downloads.onChanged reports the download over) instead of a timer; revoke the reusable URL when its backing manager closes.

Confidence: medium-high (the prune timing is in the code; the long-download trigger is environmental).


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