Unhandled "error" event. (Error: Callback called multiple times)
See original GitHub issuePlease 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:
- I have both file and console transports, but commenting out either of two doesn’t change the behaviour.
- commenting out all my custom formatting didn’t change the behaviour (except that succeeding logs looked very different now)
- From hacky-debug console logs I see that message and meta are very “casual” and similar to other succeeding cases.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top 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 >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
This error occurred for me after I had accidentally deep cloned the logger object. Hopefully that will help somebody.
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?