Mrs. Sari wraps her old callback stove in a promise for Mr. Tono: an async executor, a throw in the callback, a second call, a forgotten return. What does Mr…
Why it matters
The hardest bugs are the quiet ones: a spinner that keeps turning with no error in the console, or an error that shows up as Uncaught where nothing can catch it. Almost all of them come from an executor of the wrong shape.
The key idea
A promise settles only through its own resolve or reject, once
Common mistakes
Wrapping async work in new Promise(async …), and the promise hangs pending An async function already returns a promise: write async function pesan() { return await masakJanji() }, or use a plain executor. Never hand the Promise constructor an async function.
Putting a try/catch in an async executor, thinking it saves the outer promise The catch inside only catches; the outer promise settles only when you call reject(e). Better: drop the async executor altogether.
A spinner keeps turning with no error in the console Some promise is never resolved or rejected on one of its paths. Make every branch of the callback call one of them, and give it a time limit (AbortSignal.timeout).
Try it in this playground
Watch a ticket hang forever Run An async executor until Mr. Tono's patience runs out.
An error that escapes: Uncaught A throw in the callback, or a rejection nobody holds.
The second call is ignored Open Called back twice.
A forgotten return: eating undefined Open A forgotten return.