You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform:Linux elara 5.4.0-70-generic Mani #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Subsystem:events
What steps will reproduce the bug?
let t = new EventTarget();
t.addEventListener('foo', evt => { throw new Error("Error thrown by first listener"); });
t.addEventListener('foo', evt => console.log("Second listener received event:", evt));
t.dispatchEvent(new Event('foo'));
console.log("After dispatch");
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Unless I'm missing something, both calls to console.log should execute. This is what happens in Chrome, Safari, and Firefox (while also calling out the unhandled exception, of course).
What do you see instead?
Node does not print either log message and appears to be allowing the exception to propagate all the way out of dispatchEvent.
Additional information
The text was updated successfully, but these errors were encountered:
This was fixed by #37237. Here's the output on Node.js 16.0.0-pre:
Second listener received event: Event {
type: 'foo',
defaultPrevented: false,
cancelable: false,
timeStamp: 179.45869708061218
}
After dispatch
node:internal/event_target:639
process.nextTick(() => { throw err; });
^
Error: Error thrown by first listener
at EventTarget.<anonymous> (file://…/f.mjs:2:42)
at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:459:20)
at EventTarget.dispatchEvent (node:internal/event_target:407:26)
at file://…/f.mjs:4:3
at ModuleJob.run (node:internal/modules/esm/module_job:154:23)
at async Loader.import (node:internal/modules/esm/loader:177:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
I'm closing as I think the problem is already fixed, don't hesitate to re-open if I missed something or if the behaviour is still not spec-compliant.
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Unless I'm missing something, both calls to
console.log
should execute. This is what happens in Chrome, Safari, and Firefox (while also calling out the unhandled exception, of course).What do you see instead?
Node does not print either log message and appears to be allowing the exception to propagate all the way out of
dispatchEvent
.Additional information
The text was updated successfully, but these errors were encountered: