Repository navigation
Stop the worker pool respawning workers that can't start - #353
Merged
Merged
Conversation
When workers can't load (e.g. a worker script served with a non-JavaScript MIME type, a CSP, or a network failure), the pool only fell back to inline once no slots were left. With several tasks queued it starts several workers, so each failure left others still starting, and the pool replaced the failed one, forever: thousands of worker starts a second, with the queued tasks never running. Before any worker has been ready, a start failure now isn't replaced; the pool waits for the workers still starting and goes inline when the last one fails. Adds a test against the built library, which points the pool at a worker that throws on load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Later startup failures can still trigger an unbounded respawn loop after any worker has previously become ready.
1 open finding
What changed in this PR
Prevents endless worker respawning during initial startup failures and adds bundled-library regression coverage.
Changes:
- Defers inline fallback until all starting workers fail.
- Tests failed worker startup with queued tasks.
| File | Description |
|---|---|
src/lib/workers/worker-queue.ts |
Adjusts worker startup-failure handling. |
test/worker-queue-bundled.test.mjs |
Adds bundled worker failure regression test. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
/deploy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


When workers can't load (e.g. a worker script served with a non-JavaScript MIME type, a CSP, or a network failure), the pool only fell back to inline once no slots were left. With several tasks queued it starts several workers, so each failure left others still starting, and the pool replaced the failed one, forever: thousands of worker starts a second, with the queued tasks never running.
Before any worker has been ready, a start failure now isn't replaced; the pool waits for the workers still starting and goes inline when the last one fails. Adds a test against the built library, which points the pool at a worker that throws on load.