Propagate abort reason from external signal in runner - #17
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR improves abort signal handling by propagating the abort reason from external signals to the internal abort controller. Previously, when an external signal was aborted (e.g., due to a timeout), the reason for the abort was lost when propagating to the internal controller, making it difficult to distinguish between different types of cancellation.
Key Changes:
- Modified the abort event listener to pass the external signal's reason when aborting the internal controller
- This enables proper timeout detection downstream via the
isTimeoutErrorfunction
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| options?.signal?.addEventListener("abort", () => { | ||
| // Pass the reason from external signal to internal controller | ||
| controller.abort(options.signal?.reason); | ||
| }); |
There was a problem hiding this comment.
This change introduces abort reason propagation but lacks test coverage. The PR description mentions tests that should verify timeout error detection and manual cancellation, but these tests haven't been added yet. Consider adding a test that:
- Creates an external AbortSignal with AbortSignal.timeout()
- Passes it to runner.run() via options.signal
- Verifies that when the timeout fires, the internal signal receives the TimeoutError reason
- Confirms that isTimeoutError() correctly identifies the error as a timeout
This would ensure the abort reason propagation works as intended and doesn't break in future changes.
Summary
Why
Previously, when an external abort signal was received, the runner would abort its internal controller without preserving the original abort reason. This meant that timeout errors or other abort reasons were lost during propagation, making it difficult to distinguish between different types of cancellation (timeout vs. manual cancellation).
By propagating the
reasonproperty from the external signal, the abort context is preserved throughout the execution chain, enabling proper error handling and timeout detection downstream.Test Plan
deno task verifyto ensure all tests pass