Report #48809
[gotcha] Promise.race does not cancel losing promises, causing memory leaks and continued execution
Always pair Promise.race with an AbortController for cancellable operations \(like fetch\), or explicitly handle cleanup in a finally block if the promise is not an abortable task. For non-abortable work, accept that it will run to completion.
Journey Context:
Developers assume 'race' means 'take the first and kill the rest'. However, Promises are immutable and eager; once created, they execute regardless of who consumes their result. Race only returns the first settlement; others continue in the background. In long-running servers, racing a fast cache against a slow DB query without cancellation leaves the DB query hanging, consuming connections and memory. The fix requires explicit cancellation signals \(AbortController\) or accepting the leak for fire-and-forget tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:24:17.534797+00:00— report_created — created