How to Detect an Unhandled Rejection

Learn how to detect unhandled rejections and how a web browser tracks them.

We'll cover the following

In the first generation of promises, a rejected promise without a rejection handler would silently fail. Many considered this the biggest flaw in the specification because it was the only part of the JavaScript language that didn’t make errors apparent. Later, JavaScript runtimes instituted console warnings to at least notify developers when unhandled rejections occurred, and some runtime environments decided to throw errors. Eventually, unhandled rejection tracking was added to the JavaScript specification.

Handling promise rejection

Determining whether a promise rejection was handled isn’t straightforward due to the nature of promises. For instance, consider this example:

Get hands-on with 1400+ tech skills courses.