Repository navigation
fix(polling): honor an already-aborted signal - #955
Merged
BigBen-7 merged 1 commit intoOct 17, 2026
Merged
Conversation
attachAbort returned a no-op when signal.aborted was already true, so cancelled was never set and watch() polled until the timeout. Seed cancelled from signal.aborted and check it at the top of the loop, before the first poll, throwing PollingAbortedError.
|
@Spaully Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
PollingService.watch()now honours an abort signal that is already aborted when polling starts, and checks the cancellation state before the first status lookup. A pre-aborted signal throwsPollingAbortedErrorimmediately instead of polling until the timeout.Problem
attachAbort()returned a no-op cleanup function whensignal.abortedwas alreadytrue, so the localcancelledflag was never set. In addition,watch()only read that flag after performing a status check, never before the first one. A caller that passed an already-aborted signal therefore sawwatch()poll until its timeout rather than cancelling.Changes Made
src/utils/polling/polling.service.ts:cancelledis now seeded fromoptions.signal?.aborted, andwatch()checkscancelledat the top of each loop iteration — before the firstcheckStatus()call — throwingPollingAbortedErrorwhen set.Implementation Details
Initialising
cancelledfromsignal.abortedcovers the case where the signal is aborted beforeattachAbort()runs and therefore never fires anabortevent. Moving the guard to the top of the loop ensures cancellation is observed before the first poll as well as between polls, while the existing success and timeout checks remain unchanged.Closes #816
Closes #815
Closes #814
Closes #813