Skip to content

fix(polling): honor an already-aborted signal - #955

Merged
BigBen-7 merged 1 commit into
Lead-Studios:mainfrom
Spaully:fix/issue-816-honor-aborted-signal
Oct 17, 2026
Merged

BigBen-7 merged 1 commit into
Lead-Studios:mainfrom
Spaully:fix/issue-816-honor-aborted-signal

Conversation

@Spaully

@Spaully Spaully commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

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 throws PollingAbortedError immediately instead of polling until the timeout.

Problem

attachAbort() returned a no-op cleanup function when signal.aborted was already true, so the local cancelled flag 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 saw watch() poll until its timeout rather than cancelling.

Changes Made

  • src/utils/polling/polling.service.ts: cancelled is now seeded from options.signal?.aborted, and watch() checks cancelled at the top of each loop iteration — before the first checkStatus() call — throwing PollingAbortedError when set.

Implementation Details

Initialising cancelled from signal.aborted covers the case where the signal is aborted before attachAbort() runs and therefore never fires an abort event. 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

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.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@BigBen-7
BigBen-7 merged commit e3c5966 into Lead-Studios:main Oct 17, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants