Skip to content

Commit

Permalink
node: set process._eventsCount to 0 on startup
Browse files Browse the repository at this point in the history
process is an EventEmitter. There are operations that increment and
decrement the _eventsCount property of an EventEmitter.
process._eventsCount would previously get set to NaN. This change makes
process._eventsCount be calculated as expected.

PR-URL: #5208
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
evanlucas authored and Myles Borins committed Mar 1, 2016
1 parent 4a6e2b2 commit 78d6488
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

function startup() {
var EventEmitter = NativeModule.require('events');
process._eventsCount = 0;

Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, {
constructor: {
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-process-emit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ process.on('SIGPIPE', common.mustCall((data) => {
process.emit('normal', 'normalData');
process.emit(sym, 'symbolData');
process.emit('SIGPIPE', 'signalData');

assert.strictEqual(isNaN(process._eventsCount), false);

0 comments on commit 78d6488

Please sign in to comment.