@@ -848,6 +848,32 @@ test('basic prettifier tests', (t) => {
848
848
t . doesNotThrow ( pinoPretty )
849
849
} )
850
850
851
+ t . test ( 'does not call fs.close on stdout stream' , ( t ) => {
852
+ t . plan ( 2 )
853
+ const destination = pino . destination ( { minLength : 4096 , sync : true } )
854
+ const prettyDestination = pinoPretty ( { destination, colorize : false } )
855
+ const log = pino ( prettyDestination )
856
+ log . info ( 'this message has been buffered' )
857
+ const chunks = [ ]
858
+ const { close, writeSync } = fs
859
+ let closeCalled = false
860
+ fs . close = new Proxy ( close , {
861
+ apply : ( target , self , args ) => {
862
+ closeCalled = true
863
+ }
864
+ } )
865
+ fs . writeSync = new Proxy ( writeSync , {
866
+ apply : ( target , self , args ) => {
867
+ chunks . push ( args [ 1 ] )
868
+ return args [ 1 ] . length
869
+ }
870
+ } )
871
+ destination . end ( )
872
+ Object . assign ( fs , { close, writeSync } )
873
+ t . match ( chunks . join ( '' ) , / I N F O .+ : t h i s m e s s a g e h a s b e e n b u f f e r e d / )
874
+ t . equal ( closeCalled , false )
875
+ } )
876
+
851
877
t . test ( 'stream usage' , async ( t ) => {
852
878
t . plan ( 1 )
853
879
const tmpDir = path . join ( __dirname , '.tmp_' + Date . now ( ) )
0 commit comments