diff --git a/lib/internal/event_target.js b/lib/internal/event_target.js index 2ec36095165fc1..02166bcc783fe2 100644 --- a/lib/internal/event_target.js +++ b/lib/internal/event_target.js @@ -329,7 +329,7 @@ class EventTarget { if (signal) { if (signal.aborted) { - return false; + return; } // TODO(benjamingr) make this weak somehow? ideally the signal would // not prevent the event target from GC. diff --git a/test/parallel/test-eventtarget-whatwg-signal.js b/test/parallel/test-eventtarget-whatwg-signal.js index 8573d2b4aea5bb..dfe5810180d90e 100644 --- a/test/parallel/test-eventtarget-whatwg-signal.js +++ b/test/parallel/test-eventtarget-whatwg-signal.js @@ -25,7 +25,11 @@ const { controller.abort(); et.dispatchEvent(new Event('test')); strictEqual(count, 2, 'Aborting on the controller removes the listener'); - et.addEventListener('test', handler, { signal: controller.signal }); + // See: https://github.com/nodejs/node/pull/37696 , adding an event listener + // should always return undefined. + strictEqual( + et.addEventListener('test', handler, { signal: controller.signal }), + undefined); et.dispatchEvent(new Event('test')); strictEqual(count, 2, 'Passing an aborted signal never adds the handler'); }