pechkin
pechkin copied to clipboard
Finish Event don't fired
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)
}
}
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)?