[BUG] Callback called multiple times
See original GitHub issueDescribe the bug I’m currently using your lib to parsing a stream received from a S3 bucket. But after some time I’ve noticed the following error:
{
"errorType": "Error",
"errorMessage": "Callback called multiple times",
"code": "ERR_MULTIPLE_CALLBACK",
"stack": ["Error [ERR_MULTIPLE_CALLBACK]: Callback called multiple times", " at CsvParserStream.afterTransform (_stream_transform.js:89:31)", " at callNext (/var/task/node_modules/@fast-csv/parse/build/src/CsvParserStream.js:93:28)", " at /var/task/node_modules/@fast-csv/parse/build/src/CsvParserStream.js:119:28", " at CsvParserStream.transformRow (/var/task/node_modules/@fast-csv/parse/build/src/CsvParserStream.js:165:13)", " at iterate (/var/task/node_modules/@fast-csv/parse/build/src/CsvParserStream.js:116:25)", " at Immediate._onImmediate (/var/task/node_modules/@fast-csv/parse/build/src/CsvParserStream.js:97:40)", " at processImmediate (internal/timers.js:456:21)", " at process.topLevelDomainCallback (domain.js:137:15)"]
}
Parsing or Formatting?
- Formatting
- Parsing
To Reproduce Here’s the current coding that’s triggering this error:
return new Promise((resolve): void => {
stream
.pipe(parseCsv())
.on('data', async (row: string[]) => {
buffer.push(row);
if (buffer.length === this.bufferLimit) {
const bufferToBeConsumed = buffer;
buffer = [];
await this.upsertCsvRowsByExportType(bufferToBeConsumed, filename);
}
})
.once('end', async () => {
if (buffer.length) {
const bufferToBeConsumed = buffer;
buffer = [];
await this.upsertCsvRowsByExportType(bufferToBeConsumed, filename);
resolve();
}
});
});
The lib isn’t used in any other place.
Expected behavior No error should occur during parsing process.
Screenshots
Desktop (please complete the following information):
- Lambda function
- Node Version 12.13
- Lib Version 4.3.1
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Callback called multiple times in 16.8.0 with Stream & pipeline ...
Node has always (incorrectly) caused the callback to be executed twice. However as a result of the code changes between 16.4.2 and 16.8...
Read more >ERROR! Callback called multiple times** JHipster version 7.3 ...
Callback called multiple times when generating JHipter applications or entities, you should verify the Node JS version.
Read more >How to prevent disasters caused by the callback getting called ...
are you sure, the callback is called several times? sounds like the a callback is attached several time to me. this can happen...
Read more >MongoDB Compass GUI - Callback called multiple times
and select the file I want, I get the following error: · If, instead of chosing Import File, I chose Insert Document ·...
Read more >Component conversion failed - Trailhead - Salesforce
Component conversion failed : Callback called multiple times. Hi everyone, I'm trying to deploy a class in vscode but unfortunately I got an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just published
v4.3.2
, I’ll leave this issue open for a couple of days in case it does not completely address it.Thank you for the bug report!
Just issue #464 to try to address this, instead of calling done again in the catch block it will now re throw the error.
I’ll update once I publish