Repository navigation
Conversation
zwave-js-bot
marked this pull request as ready for review
October 5, 2026 09:56
A task with the Restart interrupt behavior can be reset while it waits for a yielded promise. The promise handlers now check that the generator is still the same, so a late result or rejection no longer reaches the restarted run. The late finally handler also no longer clears the wait promise of the restarted run.
AlCalzone
force-pushed
the
claude/waddle-restart-promise-bug
branch
from
October 6, 2026 09:08
5459d42 to
aeeb22d
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The regression test does not cover stale fulfillment or stale finally cleanup behavior.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Extends #39’s reset-safety logic to yielded promises.
Changes:
- Ignores stale promise results, errors, and cleanup.
- Adds a stale-rejection regression test.
- Updates the changelog.
| File | Description |
|---|---|
src/Task.ts |
Guards promise handlers by generator identity. |
src/Task.test.ts |
Tests stale rejection after restart. |
README.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.

Stacked on #39. Merge that first. This PR's diff only shows the change on top of it.
The issue: A task with
interrupt: TaskInterruptBehavior.Restartcan be reset by a higher-priority task while it waits for a yielded promise. The promise'sthen,catchandfinallyhandlers did not check for that. If the old promise rejected after the restart,waitErrorwas set and the nextstep()threw it into the fresh generator viagen.throw(waitError). The latefinallyalso cleared thewaitForPromiseof the restarted run.The fix: The yielded-promise handlers now use the same check as the subtask handlers from #39.
thenandcatchonly store the result or error ifgenerator === gen.finallyreturns early when the generator has changed.Test:
A restarted task ignores a rejection of the promise it waited for before the restartinterrupts a waiting Restart task and rejects the old promise while the restarted run waits for a new one. It failed with the old error before the fix. All 65 tests pass.