Repository navigation
fix: exit the database-maintenance worker test harness on a detached-spawn error (#9059) - #9063
Merged
Merged
Conversation
…or (#9059) launch()'s inline child script only set process.exitCode on the handle's 'error' event, unlike its 'close' handler which also calls process.exit(). The reusable 'released' poll interval never clears while the operation's control dir still exists (true for every non-release outcome, including a refusal), so an 'error' instead of 'close' left the harness process running forever with no application-level timeout — only the outer run() spawn's own 30s timeout eventually reaped it via SIGTERM, surfacing as exitCode: null instead of a real status. That matches the Windows CI symptom: the two-hop PowerShell supervisor chain spawnDatabaseMaintenanceWorker drives on Windows can miss its PID deadline under load and emit 'error', which this harness bug then stretched into a spurious 30s timeout instead of a fast, readable failure.
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.
What
Fixes a real hang in
server/lib/databaseMaintenanceWorker.test.js'slaunch()test helper that most likely explains the "worker exit not observed within 30s on Windows CI" flake.Root cause
launch()'s inline child script attaches both an'error'and a'close'handler to thespawnDatabaseMaintenanceWorker()handle, plus areleasedpoll interval used to detect the release-admission outcome. That interval only clears once the operation's control directory disappears — which is not the case for a refusal (the control dir stays under the fence).The
'close'handler callsprocess.exit()to force the harness process to exit even while that interval is still running. The'error'handler did not — it only setprocess.exitCode, leaving the still-running interval to keep the process alive indefinitely. IfspawnDatabaseMaintenanceWorker's detached-spawn machinery ever emits'error'instead of'close'(e.g. the Windows two-hop PowerShell supervisor missing its PID deadline under CI load), the harness process never exits on its own. The only thing that eventually reaps it is the outerrun()spawn's owntimeout: 30_000(spawn(..., { timeout: 30_000 })), which SIGTERMs the hung process — producing exactly the observedexitCode: nullaround 30s instead of a real status.Fix
child.on('error', …)now also callsprocess.exit(), matching the'close'handler, so a detached-spawn error surfaces immediately as a real exit code/stderr instead of stalling the harness for the full outer timeout.Test plan
server/node_modules/.bin/vitest run lib/databaseMaintenanceWorker.test.js— 8/8 passing locally (macOS).npm run pregate— green (40 files / 594 tests).provider:codex, low effort) — no findings.This was not reproduced on Windows CI directly (the original failure is a suspected flake), but the fix removes a concrete, demonstrable hang that the existing code left in place for any
'error'outcome, and does not raise any timeout.Closes #9059