Skip to content

Wait for the service worker before starting a download - #67

Merged
rthellend merged 1 commit into
mainfrom
fix-download-race
Oct 7, 2026
Merged

rthellend merged 1 commit into
mainfrom
fix-download-race

Conversation

@rthellend

Copy link
Copy Markdown
Contributor

The app unregisters the service worker when it starts, and the first download registers it again. register() resolves before the new service worker is activated and controls the page, so the stream request could go to the network instead. The stream was never requested and Download waited forever. This made TestDownload fail on GitHub.

NewStreamHelper now waits until the service worker controls the page, and Download returns an error if the stream doesn't start within 10 seconds. The test stream hook also returns an error on a non-200 status.

The app unregisters the service worker when it starts, and the first
download registers it again. register() resolves before the new service
worker is activated and controls the page, so the stream request could
go to the network instead. The stream was never requested and Download
waited forever. This made TestDownload fail on GitHub.

NewStreamHelper now waits until the service worker controls the page,
and Download returns an error if the stream doesn't start within 10
seconds. The test stream hook also returns an error on a non-200 status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rthellend
rthellend marked this pull request as ready for review October 7, 2026 19:24
@rthellend
rthellend merged commit cc675ac into main Oct 7, 2026
5 checks passed
@rthellend
rthellend deleted the fix-download-race branch October 7, 2026 19:25
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