mafintosh / mafintosh/csv-parser
async/await in event headers not work as expected
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 143
- PR merge metrics
- No merged PRs in 30d
Description
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start from the csv() entry point and trace how the headers event interacts with the pipe; run the supplied Node.js reproduction. Done means asynchronous headers handling finishes before the writable stream receives its first row.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100