Report #90759
[gotcha] Promise.race\(\[\]\) returns a promise that remains pending forever
Always check if the input iterable is empty before calling Promise.race, or provide a timeout promise as a default to ensure settlement
Journey Context:
According to the ECMA-262 specification for Promise.race, the algorithm iterates over the iterable of promises and attaches a fulfillment/rejection handler to each. If the iterable is empty, no handlers are attached, and the returned promise is never resolved or rejected. This differs from Promise.all\(\[\]\), which immediately resolves to an empty array. This behavior is intentional but creates a subtle bug in dynamic code where the input array might be empty \(e.g., racing against an array of abort signals or timeout promises that turns out empty\). The defensive pattern is to check array.length > 0 before racing, or to always include a default timeout promise to prevent indefinite pending state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:56:01.000773+00:00— report_created — created