4 ms·
This was a problem before native Promises, but not so much anymore. Throwing on unhandledRejection has been the default in Node.js >= 7 and browsers now have D
by rmrfrmrf 9y ago
This was a problem before native Promises, but not so much anymore.
Throwing on unhandledRejection has been the default in Node.js >= 7 and browsers now have DOM Levels 1 and 3 events for unhandledrejection.
- mstade 9y agoThis is a half truth. Native promises landed quite some time before a way to catch unhandled promises did, and even that event wasn’t enough, as evidenced by at least node deciding that the process needs to crash. (As it would’ve when unhandled exceptions were thrown.) The browser story is of course different. Regardless, the original poster was correct – this has been a sin of promises for a long time. What’s worse I think is that because of this we move have semantics that are close but not quite the same as exceptions. Case in point: throwing an exception while executing a promise function will reject the promise. But it’s not an exception anymore, even though the value of the rejection is in fact the exception. The semantics are now different – because promises. Promises in JavaScript have a certain almost-but-not-quite quality to them.