I was having a hard time understanding why I was getting "uncaught exception" errors in the console, although the promise reject was actually caught and my code was running as expected.
Upon investigation, I discovered the error was not happening on other browsers, and it seems to be a bug in Pale Moon.
Results:But this one does not (I only reversed the order):Thus, I suspect there may be some race condition.
Additionally:![Razz :P]()
Maybe a some point in the await call, the promise reject is converted to a throw, whereas it shouldn't be, as it is handled by the .catch(). And that "leftover throw" doesn't break execution, while still being logged.
Upon investigation, I discovered the error was not happening on other browsers, and it seems to be a bug in Pale Moon.
CODE:
document.body.addEventListener('click', async function () { async function usingThrow() { throw Error('Using throw'); } await usingThrow().catch(err => console.log('Caught: ' + err));});document.body.addEventListener('click', async function () { async function usingPromiseReject() { return Promise.reject('Using Promise.reject'); } await usingPromiseReject().catch(err => console.log('Caught: ' + err));});
Note this code also causes an error:Caught: Using Promise.reject
Caught: Error: Using throw
uncaught exception: Using Promise.reject
CODE:
document.body.addEventListener('click', async function () { async function usingPromiseReject() { return Promise.reject('Using Promise.reject'); } await usingPromiseReject().catch(err => console.log('Caught: ' + err)); async function usingThrow() { throw Error('Using throw'); } await usingThrow().catch(err => console.log('Caught: ' + err));});
CODE:
document.body.addEventListener('click', async function () { async function usingThrow() { throw Error('Using throw'); } await usingThrow().catch(err => console.log('Caught: ' + err)); async function usingPromiseReject() { return Promise.reject('Using Promise.reject'); } await usingPromiseReject().catch(err => console.log('Caught: ' + err));});
Additionally:
- The error happens only when using an event handler. There is no error if directly executing the code.
- For the code causing errors, sometimes there is no error on the first clicks.

Maybe a some point in the await call, the promise reject is converted to a throw, whereas it shouldn't be, as it is handled by the .catch(). And that "leftover throw" doesn't break execution, while still being logged.