feat: handle full rerun by resetting the rerun key instead of crashing - #27
Merged
Conversation
Port of factorialco/specbandit#26. When the shared queue was re-pushed while a runner still holds rerun memory from a previous run (a full rerun), delete the stale rerun key and steal from the shared queue like a classic run, re-recording as we go — instead of crashing with exit 1.
beagleknight
added a commit
that referenced
this pull request
Aug 12, 2026
…28) Mirrors specbandit (Ruby) #27. The queue key is scoped by CI run, not by CI attempt. That is deliberate: re-running a single failed runner does not re-run the job that pushed, so the runner must still find the queue and the published marker the first attempt created. The cost is that the producer is not idempotent. A producer that pushes and then fails, or that is re-run with the whole workflow, appends a second copy of the work list. Every file is then enqueued twice, the suite runs twice, and any two copies that reach the same worker are loaded twice in one process. Add RedisQueue#clear, which removes the queue and its published marker in one DEL, and expose it two ways: - `specbandit push --reset` empties the key immediately before the RPUSH. - `specbandit reset --key KEY` does the same as a standalone command. Reset is opt-in, so `push` keeps its current meaning and appending to a queue stays possible. `reset` is registered as a boolean flag in the argument parser. A flag missing from that list consumes the next token as its value, so `push --reset a.test.ts` would otherwise lose the file. Per-runner rerun and failed keys are left alone, so a single-runner re-run can still replay its own files. Nothing is cleared when there is nothing to push in its place: dropping the marker on its own would make every worker on that key crash as "never published". Also closes a version drift. The VERSION constant said 0.10.0 while the package was at 1.3.0, so `--version` and the report JSON both reported a version nobody shipped. It cannot import package.json, because tsconfig rootDir is src, so the release workflow now rewrites it alongside the package.json bump.
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.
Port of the Ruby version's factorialco/specbandit#26 to the JS version.
Problem
The work-mode decision table treated "published + shared queue has data + rerun key has data" as a weird/inconsistent state and crashed with exit 1. That state occurs legitimately: a full rerun, where the queue is re-pushed while a runner still carries rerun memory from a previous run.
Change
Instead of crashing, the worker now:
RedisQueue#delete,DELunder the usual retry wrapper) before the first steal, so it cannot wipe freshly recorded batches.Updated decision table:
Tests
worker.test.tsas a full-rerun suite: asserts the delete happens before any steal, stolen batches are re-recorded to the rerun key, exit 0, and the output explains the reset.#deletespec toredisQueue.test.ts.npm test— 141 tests, 0 failures.npm run typecheckclean.README decision table and Redis-command summary updated accordingly.
No version bump included, matching the Ruby PR.