Skip to content

[BUG] Fix: download progress indicator and streaming race condition#25

Open
grMLEqomlkkU5Eeinz4brIrOVCUCkJuN wants to merge 2 commits intorebane2001:manefrom
grMLEqomlkkU5Eeinz4brIrOVCUCkJuN:fix/sw-streaming-response-race-condition
Open

[BUG] Fix: download progress indicator and streaming race condition#25
grMLEqomlkkU5Eeinz4brIrOVCUCkJuN wants to merge 2 commits intorebane2001:manefrom
grMLEqomlkkU5Eeinz4brIrOVCUCkJuN:fix/sw-streaming-response-race-condition

Conversation

@grMLEqomlkkU5Eeinz4brIrOVCUCkJuN
Copy link
Contributor

@grMLEqomlkkU5Eeinz4brIrOVCUCkJuN grMLEqomlkkU5Eeinz4brIrOVCUCkJuN commented Feb 21, 2026

The progress bar for loading smoldata.json was broken since it was creating the progress-monitored respons, but it was never actually using it. (the incorrect original response was returned)

There was also another race condition bug that gets fixed in this PR.
When the client navigates away or does something to have the context removed or somehow made it unavailable, before the stream started, the response would just fail. Now it falls back to streaming without progress updates instead of breaking.

Also I refactored progressMonitor to an async-await pattern since the .then had the closure variable that made it awkward to handle null cases.

I also added a gitignore file for convenience, but you are free to edit this PR's commits and erase that as I see that the pattern of this project seem to be hosted directly, apologies in advance.

grml added 2 commits February 22, 2026 00:39
- prevents contributors from committing the  file
  progressMonitor() was being called but its return value was discarded.
  The original networkResponse was cached and returned instead, meaning
  the monitored ReadableStream was never consumed and progress events
  were never sent to the client.

  Changes:
  - Capture and return monitoredResponse instead of networkResponse
  - Cache the monitored response so progress works on cache hits too
  - Refactor progressMonitor to async/await for cleaner flow
  - Handle null client gracefully (stream data without progress events)
@grMLEqomlkkU5Eeinz4brIrOVCUCkJuN
Copy link
Contributor Author

Also it is one of my first few times working with service workers, so do let me know if there is anything I should know about. Have a nice day.

@grMLEqomlkkU5Eeinz4brIrOVCUCkJuN
Copy link
Contributor Author

You may also need to bump the version, cheers in advance.

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