mafintosh / mafintosh/csv-parser

[category- help] .on('end', ...) not waiting till process inside .on('data', ...) is completed.

Open
#206 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.5k
Forks
143
PR merge metrics
No merged PRs in 30d

Description

here is the flow of code for what i am doing
```
const results = [];
fs.createReadStream('MainVerbs.csv')
.pipe(csv())
.on('data', async function (row) {
await promiseReturningFunction(row['v1'])
.on('end', () => {
console.log('done');
})
```

Problem is that, `.on('end', ...)` end is being fired before the time consuming processing on all rows is done.
I tried using async await in the `.on('data', ...)` section but it didn't make any difference

how do i work with this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file or test; start by reproducing the createReadStream().pipe(csv()) chain and its data and end handlers. Check the parser's documented event behavior and establish how completion of asynchronous row processing should be verified; done means the required row work is complete before completion is reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.