Report #16725
[gotcha] Promise.race with empty array never settles \(hangs forever\)
Guard against empty iterables before racing; use Promise.all for empty checks or Promise.any \(which rejects immediately on empty\).
Journey Context:
Promise.all\(\[\]\) resolves immediately to \[\]. Promise.any\(\[\]\) rejects immediately with AggregateError. However, Promise.race\(\[\]\) returns a promise that never settles because there are no promises to race. This asymmetry is surprising and causes subtle hangs in dynamic code that builds an array of promises that might end up empty \(e.g., filtering an array before racing\). The fix is to check length or use Promise.any for 'first success' semantics.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:22:51.300230+00:00— report_created — created