7 Matching Annotations
- Jan 2022
-
-
NODE_OPTIONS=--unhandled-rejections=none node
-
-
blog.atomist.com blog.atomist.com
-
My gut told me calling an async function from the setTimeout callback was a bad thing. Since the setTimeout machinery ignores the return value of the function, there is no way it was awaiting on it. This means that there will be an unhandled promise. An unhandled promise could mean problems if the function called in the callback takes a long time to complete or throws an error.
-
-
github.com github.com
-
Fundamentally, I think promise rejection is substantially different than "throwing" under normal synchronous flow.
-
const promise = Promise.reject(new Error("Something happened!")); setTimeout(async () => { // You want to process the result here... try { const result = await promise; console.log(`Hello, ${result.toUpperCase()}`) } // ...and handle any error here. catch (err) { console.error("There was an error:", err.message); } }, 100);
-
-
javascript.info javascript.info
-
we should have the unhandledrejection event handler (for browsers, and analogs for other environments) to track unhandled errors and inform the user (and probably our server) about them, so that our app never “just dies”.
-
What happens when a regular error occurs and is not caught by try..catch? The script dies with a message in the console. A similar thing happens with unhandled promise rejections.
-
-
thecodebarbarian.com thecodebarbarian.com
-
There are a lot of nasty gotchas with unhandled rejections. That's why Node.js gives you a mechanism for globally handling unhandled rejections.
-