MCPcopy Index your code
hub / github.com/nodejs/node / createWriteErrorHandler

Function createWriteErrorHandler

lib/internal/console/constructor.js:383–401  ·  view source on GitHub ↗
(instance, streamSymbol)

Source from the content-addressed store, hash-verified

381
382// Make a function that can serve as the callback passed to `stream.write()`.
383function createWriteErrorHandler(instance, streamSymbol) {
384 return (err) => {
385 // This conditional evaluates to true if and only if there was an error
386 // that was not already emitted (which happens when the _write callback
387 // is invoked asynchronously).
388 const stream = streamSymbol === kUseStdout ?
389 instance._stdout : instance._stderr;
390 if (err !== null && !stream._writableState.errorEmitted) {
391 // If there was an error, it will be emitted on `stream` as
392 // an `error` event. Adding a `once` listener will keep that error
393 // from becoming an uncaught exception, but since the handler is
394 // removed after the event, non-console.* writes won't be affected.
395 // we are only adding noop if there is no one else listening for 'error'
396 if (stream.listenerCount('error') === 0) {
397 stream.once('error', noop);
398 }
399 }
400 };
401}
402
403function timeLogImpl(consoleRef, label, formatted, args) {
404 if (args === undefined) {

Callers 1

constructor.jsFile · 0.85

Calls 2

listenerCountMethod · 0.80
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…