Uncaught Promise rejection
JavaScript Programming Language
Severity: ModerateWhat Does This Error Mean?
This warning means a Promise failed (was rejected) but no code was in place to handle that failure. Promises are how JavaScript handles tasks that take time — like fetching data from the internet. When one fails and there is no error handler, JavaScript logs this warning to tell you an error was silently ignored.
Affected Models
- All browsers
- Node.js
- Deno
- Any JavaScript runtime
Common Causes
- A fetch() request failed but there is no .catch() to handle the error
- An async function threw an error but was called without await or error handling
- A Promise was rejected and no .catch() or try/catch was provided
- JSON.parse() failed inside an async function with no error handling
- A third-party library returned a rejected Promise that was not handled
How to Fix It
-
Find the Promise in the error. The console usually shows which Promise was rejected and on what line. Add a .catch() to that Promise.
Example: fetch('/api/data').then(res => res.json()).catch(err => console.error('Error:', err));
-
If you are using async/await, wrap your code in a try/catch block to handle any errors from awaited operations.
Example: async function loadData() { try { let data = await fetch('/api'); } catch (err) { console.error(err); } }
-
Make sure every async function that is called has its errors handled. If you call an async function without await, errors from it become unhandled rejections.
When you call an async function, either await it (and use try/catch) or chain .catch() on the returned Promise.
-
Add a global unhandled rejection listener as a safety net to log any missed errors: window.addEventListener('unhandledrejection', event => { console.error(event.reason); });
This is a catch-all safety net. It is not a replacement for proper per-Promise error handling — it just makes sure nothing is silently lost.
-
Review your async code and add meaningful error handling — not just console.log. Show the user a friendly error message, retry the operation, or fall back to default data.
Good error handling makes the difference between a polished application and one that silently breaks.
When to Call a Professional
This is a common issue in JavaScript that every developer needs to know how to handle. No professional help is needed — the fix is simply adding proper error handling to your asynchronous code. Learning to handle Promises and async/await errors is an important JavaScript skill.
Frequently Asked Questions
What is a Promise in JavaScript?
A Promise is a way to handle a task that takes time — like downloading data from the internet. Instead of freezing the page while waiting, JavaScript uses a Promise to say 'I will let you know when this is done'. A Promise can either succeed (resolve) with a result, or fail (reject) with an error. You handle these outcomes with .then() for success and .catch() for failure.
What is the difference between .catch() and try/catch with async/await?
They do the same thing — catch errors from async operations — just in different styles. .catch() chains onto a Promise: fetch(url).then(...).catch(err => ...); try/catch works with async/await: try { let data = await fetch(url); } catch(err) { ... } Both are valid. Modern JavaScript code tends to prefer async/await with try/catch because it reads more like regular synchronous code.
Will this error break my website?
An unhandled rejection will log a warning (or error in Node.js) and the failed operation will silently fail. The rest of the page may continue working, but anything that depended on the failed Promise will not behave correctly. For example, a failed data fetch might leave the page showing nothing instead of the expected content. Always handle your Promise rejections to ensure a good user experience.