Weird behavior with Promise throwing “Unhandled promise rejection” error

In order to be considered handled, rejected promises should be synchronously chained with then(..., ...) (2 arguments) or catch(...).

promise.then(() => console.log('ok')) is a separate promise that wasn’t chained with catch(...), so rejected promise will result in unhandled rejection.

If I’m in any other page (like stackoverflow.com) it throws the exception

This isn’t an exception, it doesn’t prevent a script from running normally. The way unhandled rejections are treated depends on Promise implementation. Chrome implementation results in Uncaught (in promise) console error by default.

That it doesn’t appear on some websites in Chrome means that a website set up unhandledrejection event handler that suppresses error output.

Leave a Comment