Report #59833
[gotcha] Promise constructor executes its executor function immediately and synchronously
Never perform recursive Promise construction without yielding to the event loop; defer recursion using queueMicrotask, setImmediate \(Node\), or Promise.resolve\(\).then\(\) to empty the stack between iterations
Journey Context:
The Promise constructor is often assumed to schedule the executor asynchronously, but the spec requires the executor to be called synchronously on the calling stack before the constructor returns. This causes immediate stack overflow in recursive algorithms that attempt to chain-promises synchronously \(e.g., \`new Promise\(\(res\) => recursivePromise\(\)\)\`\). To achieve async recursion, the recursive call must be deferred to a microtask or macrotask, allowing the current execution context to unwind.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:55:14.046746+00:00— report_created — created