From 9cee86e3e98dc976a17c8d79c8f391c510615b28 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Fri, 12 Feb 2016 15:14:42 -0600 Subject: [PATCH] node: set process._eventsCount to 0 on startup 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: https://github.com/nodejs/node/pull/5208 Reviewed-By: Brian White Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis --- src/node.js | 1 + test/parallel/test-process-emit.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/node.js b/src/node.js index 16e28127ac..b554e638a2 100644 --- a/src/node.js +++ b/src/node.js @@ -12,6 +12,7 @@ function startup() { var EventEmitter = NativeModule.require('events'); + process._eventsCount = 0; Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, { constructor: { diff --git a/test/parallel/test-process-emit.js b/test/parallel/test-process-emit.js index ce7d441655..f4f6d546f1 100644 --- a/test/parallel/test-process-emit.js +++ b/test/parallel/test-process-emit.js @@ -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);