pechkin icon indicating copy to clipboard operation
pechkin copied to clipboard

Finish Event don't fired

Open TomFuch opened this issue 1 year ago • 1 comments

Hi!

I dont understand, why here the finish event won't fire? pathExists comes from npm fs-extra Any hints?

for await (const { stream, filename } of files) { const filePath = /upload/${filename}

if (await pathExists(filePath)) {
    throw Error('file already exist. check protocol for errors')
  } else {
    stream.pipe(createWriteStream(filePath))

    const length = await new Promise((resolve, reject) => {
      stream
         .on('end', () => {
           console.log('read end')
           resolve(stream.bytesWritten)
         })
         .on('finish', () => {
           console.log('write finish')
           resolve(stream.bytesWritten)
         })
         .on('error', reject)
     })

     console.log(length)
  }

}

TomFuch avatar Feb 11 '24 09:02 TomFuch

Hi @TomFuch , sorry for the pretty late reply. I don't think this is enough info to help you with the issue, I can't reproduce it (and this is basically a very standard use case, literally example code. Have you resolved the issue? Or could you provide more info (surrounding code, any hints that it's Pechkin causing the problem)?

rafasofizada avatar Mar 20 '24 08:03 rafasofizada