fix: embed pool waits for worker restart, restarts on code-0 exit#3
Merged
BrainSlugs83 merged 5 commits intomainfrom Mar 27, 2026
Merged
fix: embed pool waits for worker restart, restarts on code-0 exit#3BrainSlugs83 merged 5 commits intomainfrom
BrainSlugs83 merged 5 commits intomainfrom
Conversation
531a29b to
82f4e72
Compare
Extract worker lifecycle management into embed-pool.js with: - embed() awaits pending restart instead of rejecting immediately - Worker restarts on ALL exit codes, not just non-zero - shuttingDown guard prevents restart after explicit shutdown - Configurable workerReadyTimeout for restart wait (default 30s) - Timer cleanup in rejectAllPending to prevent leaks Includes 8 new unit tests covering both bugs and fix behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n shutdown - Wrap initWorker() in try-catch inside scheduleRestart setTimeout callback to prevent permanently hung workerReadyPromise when factory throws - Store restart timer ID and clearTimeout it in shutdown() to prevent zombie worker spawning after explicit shutdown - Re-check shuttingDown flag inside setTimeout callback as belt-and-suspenders - Add 2 regression tests that prove both bugs before fix Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… failed restarts - rejectAllPending now fires on ALL exit codes (code-0 previously orphaned in-flight embeds until the 60s embed timeout) - Failed workerFactory() calls in scheduleRestart now retry with exponential backoff (delay doubles each failure, capped at maxRestartDelay) - Backoff resets to base delay after a successful restart - Removed unreachable shuttingDown guard inside setTimeout callback (clearTimeout in shutdown() already prevents the callback from firing) 7 new tests (68 total), 100% line/branch/function coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Restore clearTimeout(restartTimer) in shutdown() (primary guard) - Remove v8 ignore pragma from shuttingDown guard (backup guard) - Add monkeypatch test that neuters clearTimeout to exercise the backup guard, proving it catches the timer callback race - 69 tests, 100% line/branch/function coverage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
10b7e3f to
e6b21c0
Compare
- Add VECTOR_MEMORY_DATA_DIR env var to vector-memory-server.js and index.js for overriding the data directory (default: ~/.copilot/) - Add test-integration.js with 7 end-to-end tests that spawn the full MCP STDIO proxy, perform the JSON-RPC handshake, and exercise all tools - Tests use temp directory via VECTOR_MEMORY_DATA_DIR + random port to avoid touching real data or conflicting with running servers - Add npm run test:integration script Refs #5 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #4
Extract worker lifecycle management into embed-pool.js with:
Includes 10 unit tests covering both original bugs and edge case fixes.