Why does my promise never resolve?
Common causes
A promise only settles when resolve or reject runs. If a code path returns early, skips a callback, or throws inside a callback that nothing catches, the promise can remain pending forever. Wrapping an old callback API in a new promise is a frequent source of this bug.
Another common cause is awaiting a promise that depends on something else that is itself stuck. If one promise in a chain never settles, every promise waiting on it also stays pending, which can look like a silent hang.
- Check every branch of the function for a resolve call
- Confirm the event you wait for actually fires
- Look for a promise that is created but never returned
How to find and fix it
Add logs before and after each await to see where execution stops. Adding a timeout to a risky promise can turn a silent hang into a visible error, which makes debugging faster.
When wrapping a callback function, make sure every error path calls reject, not only the success path. Returning the promise from functions also helps avoid losing track of it.
If you suspect a hang, check whether the promise is waiting on a network call or user input that never completes. Many libraries let you set a timeout option that avoids waiting forever.
Common mistakes
- Calling resolve inside a branch that never runs.
- Forgetting to return or await a promise, so the caller never waits for it.
