question-mark
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.

Unhandled "error" event. (Error: Callback called multiple times)

See original GitHub issue

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • node -v outputs: 8.16.1
  • Operating System? Linux
  • Language? TypeScript 3.6.3

What is the problem?

Sometimes, consistently, some of the calls to log results in the following error:

Unhandled "error" event. (Error: Callback called multiple times)
      at DerivedLogger.afterTransform (./node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:82:17)
      at DerivedLogger._transform (./node_modules/winston/lib/winston/logger.js:310:7)
      at DerivedLogger.Object.<anonymous>.Transform._read (./node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:177:10)
      at DerivedLogger.Object.<anonymous>.Transform._write (./node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:164:83)
      at doWrite (./node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:405:139)
      at writeOrBuffer (./node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:394:5)
      at DerivedLogger.Object.<anonymous>.Writable.write (./node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js:303:11)
      at DerivedLogger.log (./node_modules/winston/lib/winston/logger.js:244:14)
      at DerivedLogger.(anonymous function) [as verbose] (./node_modules/winston/lib/winston/create-logger.js:95:19)

I’ve not figured out the pattern of why it fails yet.

What do you expect to happen instead?

I expect it to throw a more useful error that would help me to identify what I’m doing wrong.

Other information

It felt related to ExceptionHandler problems at https://github.com/winstonjs/winston/pull/1355 https://github.com/winstonjs/winston/issues/1289 https://github.com/winstonjs/winston/issues/1261 https://github.com/winstonjs/winston/issues/511, but after few experiments doesn’t so:

  1. I have both file and console transports, but commenting out either of two doesn’t change the behaviour.
  2. commenting out all my custom formatting didn’t change the behaviour (except that succeeding logs looked very different now)
  3. From hacky-debug console logs I see that message and meta are very “casual” and similar to other succeeding cases.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
calvinjaramillocommented, Aug 10, 2020

This error occurred for me after I had accidentally deep cloned the logger object. Hopefully that will help somebody.

1reaction
Akuukiscommented, Nov 25, 2019

The error is back again. Went through winston code but didn’t get smarter why it arises - can anyone point in the right direction please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR! Callback called multiple times** JHipster version 7.3 ...
So, according to @MattRaible and @GaelMariou, when having the ERROR! Callback called multiple times when generating JHipter applications or ...
Read more >
Process | Node.js v19.3.0 Documentation
The 'rejectionHandled' event is emitted whenever a Promise has been rejected and an error handler was attached to it (using promise.catch() , for...
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 >
Top 10 Most Common Node.js Developer Mistakes - Toptal
The more complex the task, the worse this can get. By nesting callbacks in such a way, we easily end up with error-prone,...
Read more >
A Comprehensive Guide To Error Handling In Node.js
It is important to control the flow of the contents of the callback function by always checking for an error before attempting to...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found