Skip to content

Commit

Permalink
Handle EPIPE better in exceptional edge cases
Browse files Browse the repository at this point in the history
Fix #422
  • Loading branch information
isaacs committed Feb 19, 2018
1 parent b727234 commit 283c8e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tap.js
Expand Up @@ -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)
}
}

Expand Down
9 changes: 9 additions & 0 deletions 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()
})

0 comments on commit 283c8e6

Please sign in to comment.