Skip to content

EventTarget listener exception handling appears to deviate from the WHATWG spec #38122

@rs70

Description

@rs70
  • Version:v15.14.0
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    eventsIssues and PRs related to the events subsystem / EventEmitter.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions