Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Callback called multiple times

See original GitHub issue

Describe 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",
    "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 => {
    .on('data', async (row: string[]) => {
      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);

The lib isn’t used in any other place.

Expected behavior No error should occur during parsing process.

Screenshots Screen Shot 2020-07-08 at 13 37 48

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:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

doug-martincommented, Sep 2, 2020

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!

doug-martincommented, Sep 2, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found