Stumbled on a promise allsettled error in your Node.js application? This common issue has a well-known fix that you can apply in minutes.
The Problem
Promise.allSettled() was introduced in ES2020. If your Node.js application targets older Node.js versions (below 12.9) or uses a bundler configuration that doesn't include the necessary polyfills, you'll encounter a TypeError: Promise.allSettled is not a function at runtime.
How to Fix It
The best approach is to upgrade your Node.js version. If that's not possible, add a polyfill:
// Option 1: Polyfill for older environments
if (!Promise.allSettled) {
Promise.allSettled = (promises) =>
Promise.all(
promises.map((p) =>
Promise.resolve(p)
.then((value) => ({ status: "fulfilled", value }))
.catch((reason) => ({ status: "rejected", reason }))
)
);
}
// Option 2: Use it with proper error handling
const results = await Promise.allSettled([
fetchUsers(),
fetchOrders(),
fetchProducts(),
]);
const fulfilled = results.filter((r) => r.status === "fulfilled");
const rejected = results.filter((r) => r.status === "rejected");
if (rejected.length > 0) {
console.warn("Some requests failed:", rejected.map(r => r.reason));
}
// Process successful results
const data = fulfilled.map((r) => r.value);When to Use allSettled vs all
- `Promise.all` fails fast on the first rejection — use when all promises must succeed
- `Promise.allSettled` waits for everything and reports each result individually — use when you want partial results even if some promises fail
Node.js Version Check
Run node --version to verify your runtime. Version 12.9.0+ supports allSettled natively. For production, targeting Node 16+ or 18+ is recommended.
Track unhandled promise rejections and allSettled failures automatically with [Bugsly](https://bugsly.dev) — get full stack traces for every rejected promise in your Node.js app.
Try Bugsly Free
AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.
Get Started FreeRelated Articles
AI Error Analysis: Gimmick or Game-Changer? An Honest Review
AI-powered error analysis sounds like marketing fluff. We tested it on 100 real production errors to find out if it actually saves debugging time.
Read moreHow to Fix Permissionerror in Electron In Production
Learn how to diagnose and fix the permissionerror in Electron in production. Includes code examples and prevention tips.
Read moreFix Authentication Failed Error in Remix
Learn how to fix the Authentication Failed error in Remix. Step-by-step guide with code examples and solutions. Quick, practical guide for developers.
Read moreFix Camera Access Denied Error in Next.js
Learn how to fix the Camera Access Denied error in Next.js. Step-by-step guide with code examples and solutions. Quick, practical guide for developers.
Read more