Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish Event don't fired #4

Open
TomFuch opened this issue Feb 11, 2024 · 1 comment
Open

Finish Event don't fired #4

TomFuch opened this issue Feb 11, 2024 · 1 comment

Comments

@TomFuch
Copy link

TomFuch commented Feb 11, 2024

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)
  }

}

@rafasofizada
Copy link
Owner

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants