Version
v18.17.1, v20.5.1
Platform
Linux 6.4.10-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 11 12:20:29 UTC 2023 x86_64 GNU/Linux
Subsystem
fs, stream
What steps will reproduce the bug?
Minimal program to reproduce.
Create 2 writeStreams from a FileHandle with {autoClose: false, emitClose: false} options. Write some data to the first stream and destroy it. Try to write some data to the second stream.
import{open}from'node:fs/promises'import{pipeline}from'node:stream/promises'asyncfunctionmain(){constdestFile=awaitopen('test.tmp','w')destFile.truncate(1024)conststream0=destFile.createWriteStream({start: 0,autoClose: false,emitClose: false})conststream1=destFile.createWriteStream({start: 512,autoClose: false,emitClose: false})stream0.on('error',(err)=>{console.log('stream0 error',err)})awaitpipeline("Hello world from stream0",stream0)stream0.destroy(newError('destroyed'))try{awaitpipeline("Hello world from stream1",stream1)// emits ERR_STREAM_WRITE_AFTER_END}finally{// destFile.fd is -1 heredestFile.close()}}awaitmain()How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
Data is written, FileHandle is not closed up until close() call because emitClose: true is specified on stream creation.
What do you see instead?
ERR_STREAM_WRITE_AFTER_END is emmited when trying to write to the steream1. destFile.fd is set to -1.
Additional information
No response
Version
v18.17.1, v20.5.1
Platform
Linux 6.4.10-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Aug 11 12:20:29 UTC 2023 x86_64 GNU/Linux
Subsystem
fs, stream
What steps will reproduce the bug?
Minimal program to reproduce.
Create 2 writeStreams from a
FileHandlewith{autoClose: false, emitClose: false}options. Write some data to the first stream and destroy it. Try to write some data to the second stream.How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
Data is written, FileHandle is not closed up until
close()call becauseemitClose: trueis specified on stream creation.What do you see instead?
ERR_STREAM_WRITE_AFTER_END is emmited when trying to write to the
steream1.destFile.fdis set to -1.Additional information
No response