| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c662cc0 commit bed0560
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,10 @@ function createWriteErrorHandler(stream) { | |||
| 83 | 83 | // an `error` event. Adding a `once` listener will keep that error | |
| 84 | 84 | // from becoming an uncaught exception, but since the handler is | |
| 85 | 85 | // removed after the event, non-console.* writes won’t be affected. | |
| 86 | - stream.once('error', noop); | ||
| 86 | + // we are only adding noop if there is no one else listening for 'error' | ||
| 87 | + if (stream.listenerCount('error') === 0) { | ||
| 88 | + stream.on('error', noop); | ||
| 89 | + } | ||
| 87 | 90 | } | |
| 88 | 91 | }; | |
| 89 | 92 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const { Writable } = require('stream'); | ||
| 5 | + const { Console } = require('console'); | ||
| 6 | + const { EventEmitter } = require('events'); | ||
| 7 | + | ||
| 8 | + const stream = new Writable({ | ||
| 9 | + write(chunk, enc, cb) { | ||
| 10 | + cb(); | ||
| 11 | + }, | ||
| 12 | + writev(chunks, cb) { | ||
| 13 | + setTimeout(cb, 10, new Error('kaboom')); | ||
| 14 | + } | ||
| 15 | + }); | ||
| 16 | + const myConsole = new Console(stream, stream); | ||
| 17 | + | ||
| 18 | + process.on('warning', common.mustNotCall); | ||
| 19 | + | ||
| 20 | + stream.cork(); | ||
| 21 | + for (let i = 0; i < EventEmitter.defaultMaxListeners + 1; i++) { | ||
| 22 | + myConsole.log('a message'); | ||
| 23 | + } | ||
| 24 | + stream.uncork(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments