fix(ton): prevent polling loop from exiting due to unref'd AbortSignal.timeout timers#268
fix(ton): prevent polling loop from exiting due to unref'd AbortSignal.timeout timers#268nicolasgnr wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 nicolasgnr, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
Coverage Report |
There was a problem hiding this comment.
Unfortunately, I don't think we can accept this PR.
The behavior of AbortSignal not holding the event loop is intentional. It prevents those cascade of signals from leaking memory, and dangling contexts potentially forever (which is very bad in long-lived scripts), which is not the case with Promise.race (search for Promise.race leaks).
Instead, you should explicitly keep your event loop for the duration of your main task.
This is how we do it in cli:
ccip-tools-ts/ccip-cli/src/index.ts
Lines 161 to 169 in 2807dab
|
Thanks for the explanation and feedback @andrevmatos. It's not be best user experience as a consumer of the SDK, however, I understand the concern and the proposal / workaround. |
AbortSignal.timeout() uses unref'd timers internally in Node.js, which do not keep the event loop alive. This caused the TON transaction polling loop to exit prematurely while awaiting the next poll interval.
This change replaces timeout-based polling delays with a standard setTimeout() wrapped in Promise.race(), preserving AbortSignal cancellation semantics while ensuring the polling loop correctly keeps the process alive until completion or cancellation.`