Report #68822
[gotcha] Promise.race\(\) leaks memory when any promise never settles, retaining all promises and their closures indefinitely
Always combine Promise.race with AbortController and explicit timeouts; ensure every promise has a settlement guarantee \(e.g., \`Promise.race\(\[fetch\(...\), timeout\(5000\)\]\)\` where timeout always settles\), or use \`AbortSignal.timeout\(\)\` to force resource release
Journey Context:
Developers assume Promise.race 'cancels' the losers, but JS lacks cancellation semantics. The spec requires the race to wait for all promises to settle to maintain determinism. In long-lived apps \(SPAs, servers\), combining Promise.race with fetch without AbortController causes unbounded memory growth as aborted requests accumulate in the event loop. The alternative of \`Promise.race\(\[fetch\(\), sleep\(5000\)\]\)\` still leaks the fetch promise if it never settles; only AbortController actually releases the underlying resource.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:00:16.175030+00:00— report_created — created