You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Hackathon] Per-Attempt AbortSignal.timeout Timers Are Never Cleared (Timer/Memory Growth in Large Batches) #82
Each request attempt mints a fresh AbortSignal.timeout(this.requestTimeoutMs)
and never cancels it once the request succeeds. The underlying timer and
signal live for their full duration (120 seconds), even when the request
itself completed in milliseconds.
Root Cause
AbortSignal.timeout(...) has no built-in way to cancel the timer it
creates once the associated operation completes. The timer keeps running
until it either fires or the process exits, regardless of whether the
signal is still needed. Because a new signal is created per attempt rather
than reused or explicitly cleaned up, successful requests leave their timer
running for no benefit.
Affected Code
File
Lines
Behavior
src/lib/http.ts
431
Mints AbortSignal.timeout(this.requestTimeoutMs) per attempt
src/lib/http.ts
433
Composes the timeout signal via AbortSignal.any, with no corresponding cleanup on settle
Impact
For a single request, this is negligible: one uncollected timer for up to
120 seconds is not meaningful overhead.
For high-throughput usage, it accumulates. A test ... --wait batch can
dispatch up to 50 concurrent triggers, each followed by repeated poll GETs,
and each individual GET mints its own fresh 120-second timer regardless of
how quickly it resolves. Over the course of a long-running batch, this
results in thousands of live timers and signal objects accumulating in
memory at any given moment.
These timers are unref'd, so they do not block process exit. The impact is
memory growth during long-running batches, not a hang or a crash.
Details / implementation notes
Proposed Resolution
Replace AbortSignal.timeout(...) with an explicit AbortController paired
with setTimeout, and clear that timeout in a finally block once the
fetch settles:
Create an AbortController and a setTimeout that calls controller.abort()
at requestTimeoutMs.
Pass controller.signal into the fetch call as before, composed with any
caller-provided abort signal.
In a finally block around the fetch, call clearTimeout unconditionally,
so the timer is released immediately once the request settles, whether it
succeeded, failed, or was retried.
Confirmations
I have searched existing issues and this is not a duplicate.
I have provided my Discord identity above for reward coordination.
Activity