Report #69012
[gotcha] Promise.race with empty array never resolves or rejects
Guard against empty iterables by checking length/size first, or use Promise.race\(\[...promises, Promise.reject\(new Error\('Empty race'\)\)\]\) pattern, or prefer Promise.any with empty-check
Journey Context:
Unlike Promise.all\(\[\]\) which resolves to \[\], Promise.race\(\[\]\) returns a promise that remains pending forever per spec. This causes hangs in dynamic promise aggregation when the input array empties unexpectedly. Always validate input length > 0 or add a sentinel rejection. Note Promise.any\(\[\]\) rejects with AggregateError, which is safer for empty cases.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:19:24.765569+00:00— report_created — created