Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
617ee32
src: fix memory leak in ExternString
skomski Aug 16, 1970
56d9584
child_process: add callback parameter to .send()
bnoordhuis Aug 30, 2015
abbc8db
test: mark eval_messages as flaky
orangemocha Sep 2, 2015
6ce8f5f
doc: reorder collaborators by their usernames
jbergstroem Jul 25, 2015
47e5cf7
doc: update url doc to account for escaping
Fishrock123 Aug 28, 2015
8ca9ea2
test: refactor to eliminate flaky test
Trott Aug 29, 2015
107cbd6
child_process: check execFile and fork args
jasnell Sep 2, 2015
4a1b519
build: add --enable-asan with builtin leakcheck
skomski Aug 14, 2015
b513a33
events,lib: don't require EE#listenerCount()
Fishrock123 Sep 2, 2015
1134188
deps: upgrade V8 to 4.5.103.24
ofrobots Aug 23, 2015
a7392ff
src: apply debug force load fixups from 41e63fb
ofrobots Aug 23, 2015
709ed15
contextify: ignore getters during initialization
indutny Jul 7, 2015
06f38de
test: fix test-repl-tab-complete.js for V8 4.5
ofrobots Aug 23, 2015
39aa573
src: enable v8 deprecation warnings and fix them
bnoordhuis Jul 1, 2015
d08bb97
src: replace usage of v8::Handle with v8::Local
targos Jul 18, 2015
564e214
src: enable vector ics on arm again
ofrobots Aug 23, 2015
074315f
src: re-enable fast math on arm
targos Aug 28, 2015
64beab0
deps: upgrade V8 to 4.5.103.30
ofrobots Sep 1, 2015
fc66eed
test: fix use of `common` before required
rvagg Sep 4, 2015
eefe14c
buffer: SlowBuffer only accept valid numeric values
targos Sep 1, 2015
a338eb3
doc,test: enable recursive file watching in Windows
thefourtheye Sep 2, 2015
80bcab9
src: fix buffer overflow for long exception lines
skomski Sep 3, 2015
3a731da
src: use standard conform snprintf on windows
skomski Sep 3, 2015
a6cb3a5
doc: update environment vars in manpage and --help
silverwind Sep 4, 2015
880410d
doc: add TSC meeting minutes 2015-09-02
rvagg Sep 3, 2015
63a628d
build: fix .pkg creation tooling
rvagg Sep 4, 2015
d0c682a
deps: backport 75e43a6 from v8 upstream (again)
Aug 11, 2015
ffee40c
http: add STATUS_CODES to support Azure, CloudFlare
JungMinu Sep 5, 2015
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
Prev Previous commit
Next Next commit
events,lib: don't require EE#listenerCount()
Now parts of our public and public-ish APIs fall back to old-style
listenerCount() if the emitter does not have a listenerCount function.

Fixes: #2655
Refs: 8f58fb9

PR-URL: #2661
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Fishrock123 committed Sep 3, 2015
commit b513a3332163ad89cdb459f5877ee181b40f91c5
4 changes: 2 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function connectionListener(socket) {
parser = null;

var eventName = req.method === 'CONNECT' ? 'connect' : 'upgrade';
if (self.listenerCount(eventName) > 0) {
if (EventEmitter.listenerCount(self, eventName) > 0) {
debug('SERVER have listener for %s', eventName);
var bodyHead = d.slice(bytesParsed, d.length);

Expand Down Expand Up @@ -497,7 +497,7 @@ function connectionListener(socket) {
(req.httpVersionMajor == 1 && req.httpVersionMinor == 1) &&
continueExpression.test(req.headers['expect'])) {
res._expect_continue = true;
if (self.listenerCount('checkContinue') > 0) {
if (EventEmitter.listenerCount(self, 'checkContinue') > 0) {
self.emit('checkContinue', req, res);
} else {
res.writeContinue();
Expand Down
4 changes: 2 additions & 2 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
debug('onerror', er);
unpipe();
dest.removeListener('error', onerror);
if (dest.listenerCount('error') === 0)
if (EE.listenerCount(dest, 'error') === 0)
dest.emit('error', er);
}
// This is a brutally ugly hack to make sure that our error handler
Expand Down Expand Up @@ -586,7 +586,7 @@ function pipeOnDrain(src) {
debug('pipeOnDrain', state.awaitDrain);
if (state.awaitDrain)
state.awaitDrain--;
if (state.awaitDrain === 0 && src.listenerCount('data')) {
if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
state.flowing = true;
flow(src);
}
Expand Down
9 changes: 7 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,15 @@ EventEmitter.prototype.listeners = function listeners(type) {
};

EventEmitter.listenerCount = function(emitter, type) {
return emitter.listenerCount(type);
if (typeof emitter.listenerCount === 'function') {
return emitter.listenerCount(type);
} else {
return listenerCount.call(emitter, type);
}
};

EventEmitter.prototype.listenerCount = function listenerCount(type) {
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
const events = this._events;

if (events) {
Expand Down
2 changes: 1 addition & 1 deletion lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Stream.prototype.pipe = function(dest, options) {
// don't leave dangling pipes when there are errors.
function onerror(er) {
cleanup();
if (this.listenerCount('error') === 0) {
if (EE.listenerCount(this, 'error') === 0) {
throw er; // Unhandled stream error in pipe.
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/parallel/test-stream-pipe-without-listenerCount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
const common = require('../common');
const stream = require('stream');

const r = new stream.Stream();
r.listenerCount = undefined;

const w = new stream.Stream();
w.listenerCount = undefined;

w.on('pipe', function() {
r.emit('error', new Error('Readable Error'));
w.emit('error', new Error('Writable Error'));
});
r.on('error', common.mustCall(noop));
w.on('error', common.mustCall(noop));
r.pipe(w);

function noop() {};