fix: never let a Redis error in the exit path crash the process - #26
Closed
beagleknight wants to merge 1 commit into
Closed
fix: never let a Redis error in the exit path crash the process#26beagleknight wants to merge 1 commit into
beagleknight wants to merge 1 commit into
Conversation
A CI incident (2026-07-23, factorial run 29993494537) turned five green E2E shards red: every test passed, teardown completed, and then the process died with an uncaught 'Command timed out' from ioredis. The chain: the final steal exhausted its retries during a short Redis brownout and threw; the CLI's finally block then called queue.close(), whose QUIT command hit the same brownout and timed out 5s later. That rejection replaced the original error and escaped through the top-level await in bin.ts, which had no catch — so Node printed a raw stack and the real failure was masked. Three changes: - RedisQueue#close() never throws: QUIT failures fall back to a hard disconnect(), dropping the socket and pending commands. - bin.ts wraps CLI.run in a top-level try/catch printing a clean '[specbandit] Fatal:' message with a deterministic exit 1. - withRetries wraps the final error with the operation name and attempt count, so exhausted retries are attributable in CI logs.
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.
Context
During a short Redis brownout on the ci cluster (2026-07-23 09:29-09:34Z, factorial run 29993494537), five green E2E shards turned red: every test passed (
Failing: 0),[specbandit:cypress] Teardown complete.printed, and ~5 seconds later the process died with:The failure chain
stealhit the brownout and exhausted its 5 retries →run()threw (correct: the worker can't confirm the queue is drained).finallycalledqueue.close()→redis.quit(). QUIT is a regular command, so it hit the same brownout and itscommandTimeoutrejected 5s later — replacing the original error.bin.tshad no top-level catch, so the rejection escaped the top-levelawaitand Node 22 killed the process with a raw stack, masking the real cause.Changes
RedisQueue#close()never throws: QUIT failures fall back to a harddisconnect()(drops the socket and pending commands without a round-trip).close()runs in exit paths — a throw there can only mask the real error or crash an otherwise-green run.bin.tstop-level try/catch: clean[specbandit] Fatal: <message>instead of a raw ioredis stack, deterministic exit 1.withRetrieswraps the final error with operation + attempt count (Redis steal failed after 5 attempts: Command timed out) so CI logs are attributable at a glance.Testing
close()resolves and callsdisconnect()when QUIT rejects.vitest run: 149 passed; the 2 failures (cypressAdapter/jestAdapter"not installed" tests) also fail on cleanmainlocally — pre-existing, unrelated.