Keep a finished download's frame for a moment

Small downloads, empty or one byte, were sometimes never saved, though the worker reported them
finished and both sides logged success. The browser can read the whole response before it hands
the navigation to its download manager, and the frame was removed right then, which cancels it.
Without a delay an empty file failed 8 of 10 runs, a one byte file 4 of 10.

The download's frame now stays for DOWNLOAD_GRACE (1 s) after finished, the frame that holds the
worker still goes right away. No event tells when the browser took the download, so the 1 s is
empirical. A new test checks the retention on a paused clock, it fails without the delay and with
the worker's frame held too. The browser's timing it can't cover, TODO.md keeps a record of that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-25 19:55:45 +01:00
1 parent bd0154db68
commit 3c4e706e1f
3 files changed
+52 -9

No files matched your search

+8 -4
View File
@@ -23,7 +23,11 @@
not reproduced in 3 runs since. The report was lost; the attached logs will show the cause if it
happens again.
- `boundary: chromium sends an empty file` timed out in the first two full runs after `backend/`'s
tests were added (2026-10-25), with empty logs on both sides. It passed alone 8 times, and in 7
full runs since, one of them with a cold Vite cache. The suite without the new tests passed 4
times. Not reproduced, cause unknown.
- Small downloads (empty, one byte) were sometimes never saved, though the worker reported them
finished and both sides logged success: the browser can read the whole response before it hands
the navigation to its download manager, and removing the frame before that cancels it. Without a
delay `boundary: … sends an empty file` failed 8 of 10 runs, the one byte file 4 of 10. The
workaround `DOWNLOAD_GRACE` keeps the download's frame 1 s after finished. No event tells when the
browser took the download, so the 1 s is empirical: `boundary: … keeps a finished download's frame
for DOWNLOAD_GRACE` covers the retention, not the browser's timing. A small download that goes
missing again means it's too short.