From 283c8e64f781969a51e6f5583c84654469544968 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 19 Feb 2018 15:15:42 -0800 Subject: [PATCH] Handle EPIPE better in exceptional edge cases Fix #422 --- lib/tap.js | 4 ++-- test/regression-many-asserts-epipe.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/regression-many-asserts-epipe.js diff --git a/lib/tap.js b/lib/tap.js index 1d9a042e4..d5b3cf787 100644 --- a/lib/tap.js +++ b/lib/tap.js @@ -9,9 +9,9 @@ const _didPipe = Symbol('_didPipe') const monkeypatchEpipe = () => { const emit = process.stdout.emit - process.stdout.emit = (ev, er) => { + process.stdout.emit = function (ev, er) { if (ev !== 'error' || er.code !== 'EPIPE') - return emit.apply(process, arguments) + return emit.apply(process.stdout, arguments) } } diff --git a/test/regression-many-asserts-epipe.js b/test/regression-many-asserts-epipe.js new file mode 100644 index 000000000..2d4290cf2 --- /dev/null +++ b/test/regression-many-asserts-epipe.js @@ -0,0 +1,9 @@ +'use strict' +// See https://github.com/tapjs/node-tap/issues/422 +const t = require('../') +t.test('just a lot of asserts in rapid succession', t => { + for (let i = 0; i < 5000; i++) { + t.pass('a number is ' + i) + } + t.end() +})