1'use strict'; 2const common = require('../common'); 3const { Console } = require('console'); 4const { Writable } = require('stream'); 5 6for (const method of ['dir', 'log', 'warn']) { 7 { 8 const out = new Writable({ 9 write: common.mustCall((chunk, enc, callback) => { 10 callback(new Error('foobar')); 11 }) 12 }); 13 14 const c = new Console(out, out, true); 15 c[method]('abc'); // Should not throw. 16 } 17 18 { 19 const out = new Writable({ 20 write: common.mustCall((chunk, enc, callback) => { 21 throw new Error('foobar'); 22 }) 23 }); 24 25 const c = new Console(out, out, true); 26 c[method]('abc'); // Should not throw. 27 } 28 29 { 30 const out = new Writable({ 31 write: common.mustCall((chunk, enc, callback) => { 32 setImmediate(() => callback(new Error('foobar'))); 33 }) 34 }); 35 36 const c = new Console(out, out, true); 37 c[method]('abc'); // Should not throw. 38 } 39} 40