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

async/await in event headers not work as expected #225

Open
YuriFontella opened this issue Mar 4, 2023 · 0 comments
Open

async/await in event headers not work as expected #225

YuriFontella opened this issue Mar 4, 2023 · 0 comments

Comments

@YuriFontella
Copy link

YuriFontella commented Mar 4, 2023

  • Operating System: Linux
  • Node Version: 19
  • NPM Version: 8
  • csv-parser Version: 3.0.0

Expected Behavior

end event headers before executing writable

Actual Behavior

when there is async/await in the headers event, the next pipe is executed before finalizing event headers

How Do We Reproduce?

const readableStreamFile = fs.createReadStream('big.csv')

const writableStreamFile = new Writable({
  objectMode: true,
  async write(chunk, encoding, next) {
    console.log('writable')

    next()
  }
})

readableStreamFile
  .pipe(csv())
  .on('headers', async (headers) => {
    console.log('before headers')
    for await () {}
    // or
    await fecth()

   console.log('after headers')
  })
  .pipe(writableStreamFile)

// the output will be:
// before headers
// writable
// after headers

My dream is to arrive at the writable with all the headers event code finalized.

@YuriFontella YuriFontella changed the title async/await in event headers not work async/await in event headers not work as expected Mar 4, 2023
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

1 participant