Skip to content

Commit

Permalink
fixuP
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Oct 27, 2023
1 parent 321c41c commit 89ad099
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const {

const kCapture = Symbol('kCapture');
const kErrorMonitor = Symbol('events.errorMonitor');
const kShapeMode = Symbol('shapeMode');
const kMaxEventTargetListeners = Symbol('events.maxEventTargetListeners');
const kMaxEventTargetListenersWarned =
Symbol('events.maxEventTargetListenersWarned');
Expand Down Expand Up @@ -344,6 +345,9 @@ EventEmitter.init = function(opts) {
this._events === ObjectGetPrototypeOf(this)._events) {
this._events = { __proto__: null };
this._eventsCount = 0;
this[kShapeMode] = false;
} else {
this[kShapeMode] = true;
}

this._maxListeners = this._maxListeners || undefined;
Expand Down Expand Up @@ -686,9 +690,13 @@ EventEmitter.prototype.removeListener =
return this;

if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0)
this._eventsCount -= 1;

if (this[kShapeMode]) {
events[type] = undefined;
} else if (this._eventsCount === 0) {
this._events = { __proto__: null };
else {
} else {
delete events[type];
if (events.removeListener)
this.emit('removeListener', type, list.listener || listener);
Expand Down Expand Up @@ -750,6 +758,7 @@ EventEmitter.prototype.removeAllListeners =
else
delete events[type];
}
this[kShapeMode] = false;
return this;
}

Expand All @@ -762,6 +771,7 @@ EventEmitter.prototype.removeAllListeners =
this.removeAllListeners('removeListener');
this._events = { __proto__: null };
this._eventsCount = 0;
this[kShapeMode] = false;
return this;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/internal/streams/duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function Duplex(options) {
readable: undefined,
pipe: undefined,
unpipe: undefined,
[destroyImpl.kConstruct]: undefined,
[destroyImpl.kDestroy]: undefined,
};

this._readableState = new Readable.ReadableState(options, this, true);
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ function Readable(options) {
readable: undefined,
pipe: undefined,
unpipe: undefined,
[destroyImpl.kConstruct]: undefined,
[destroyImpl.kDestroy]: undefined,
};

this._readableState = new ReadableState(options, this, false);
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ function Writable(options) {
prefinish: undefined,
finish: undefined,
drain: undefined,
[destroyImpl.kConstruct]: undefined,
[destroyImpl.kDestroy]: undefined,
};

this._writableState = new WritableState(options, this, false);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-readline-promises-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FakeInput extends EventEmitter {
}

function isWarned(emitter) {
for (const name in emitter) {
for (const name of Object.keys(emitter)) {
const listeners = emitter[name];
if (listeners.warned) return true;

Check failure on line 25 in test/parallel/test-readline-promises-interface.js

View workflow job for this annotation

GitHub Actions / test-linux

--- stderr --- /home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25 if (listeners.warned) return true; ^ TypeError: Cannot read properties of undefined (reading 'warned') at isWarned (/home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25:19) at Object.<anonymous> (/home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:775:22) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v22.0.0-pre Command: out/Release/node --expose-internals --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-readline-promises-interface.js

Check failure on line 25 in test/parallel/test-readline-promises-interface.js

View workflow job for this annotation

GitHub Actions / test-macOS

--- stderr --- /Users/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25 if (listeners.warned) return true; ^ TypeError: Cannot read properties of undefined (reading 'warned') at isWarned (/Users/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25:19) at Object.<anonymous> (/Users/runner/work/node/node/test/parallel/test-readline-promises-interface.js:775:22) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v22.0.0-pre Command: out/Release/node --expose-internals --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /Users/runner/work/node/node/test/parallel/test-readline-promises-interface.js

Check failure on line 25 in test/parallel/test-readline-promises-interface.js

View workflow job for this annotation

GitHub Actions / test-asan

--- stderr --- /home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25 if (listeners.warned) return true; ^ TypeError: Cannot read properties of undefined (reading 'warned') at isWarned (/home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:25:19) at Object.<anonymous> (/home/runner/work/node/node/test/parallel/test-readline-promises-interface.js:775:22) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49 Node.js v22.0.0-pre Command: out/Release/node --expose-internals --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./tools/github_reporter/index.js --test-reporter-destination=stdout /home/runner/work/node/node/test/parallel/test-readline-promises-interface.js
}
Expand Down

0 comments on commit 89ad099

Please sign in to comment.