Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions test/parallel/test-event-capture-rejections.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { EventEmitter, captureRejectionSymbol } = require('events');
const { inherits } = require('util');

// Inherits from EE without a call to the
// parent constructor.
Comment on lines -7 to -8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that PR removes this check, seems important

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wich check are you talking about ?

@aduh95 aduh95 May 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment I've highlighted: having an object that inherits from EE without a call to the EE constructor (relevant section of the spec is https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about :

function NoConstructor() {}
Object.setPrototypeOf(NoConstructor.prototype, EventEmitter.prototype);
Object.setPrototypeOf(NoConstructor, EventEmitter);

we keep same behavior without using "legacy" node api

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I meant in #63178 (review)

function NoConstructor() {
}
const assert = require('node:assert');
const { EventEmitter, captureRejectionSymbol } = require('node:events');

// captureRejections param validation
{
Expand All @@ -24,7 +18,7 @@ function NoConstructor() {
});
}

inherits(NoConstructor, EventEmitter);
class NoConstructor extends EventEmitter {};

function captureRejections() {
const ee = new EventEmitter({ captureRejections: true });
Expand Down
Loading