-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
[category- help] .on('end', ...) not waiting till process inside .on('data', ...) is completed. #206
Comments
I have kind of the same problem:
It reads the first 26442 rows and throws the 'end' event then. My file has 36000 rows. Don't know how to fix that... |
Is the result returned from the promise function used inside the on('data') function? |
Have the same problem as the OP, seems that .on('end) is called before .on('data') has finished executing |
Using the return new Promise<void>((resolve, reject) => {
const stream = fs.createReadStream(path)
.pipe(csv())
.on("data", async data => {
stream.pause();
try {
await processData(data);
} finally {
stream.resume();
}
})
.on("error", error => reject(error))
.on("close", () => resolve());
}); NB: More advanced error handling is probably needed around |
here is the flow of code for what i am doing
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 differencehow do i work with this?
The text was updated successfully, but these errors were encountered: