Report #50303
[gotcha] Promise.race\(\[\]\) never settles, causing awaiting code to hang indefinitely
Always guard against empty arrays when using \`Promise.race\` by checking array length first, or provide a timeout promise as a default to ensure the race always settles.
Journey Context:
Unlike \`Promise.all\(\[\]\)\` which immediately resolves with an empty array, \`Promise.race\(\[\]\)\` returns a promise that remains in the pending state forever because there is no input promise to settle it. This is per spec \(ES2021\) but surprises developers who expect it to resolve to \`undefined\` or reject. It often appears in dynamic race conditions where an array of promises might accidentally be empty \(e.g., filtering an array of requests that results in no matches\), causing the application to hang without an error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:54:50.032740+00:00— report_created — created