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

Created on 11 Nov 2019  路  7Comments  路  Source: winstonjs/winston

Please tell us about your environment:

  • _winston version?_

    • [ ] winston@2

    • [x] 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.

Most helpful comment

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

All 7 comments

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?

I have the same issue.

@Akuukis, did you find any solutions or workarounds?

@barinbritva No, I still have no clue.

@Akuukis, that's strange only we have this issue.

I thought maybe it's something not related with Winston and I did clean install of all project dependencies, but to no avail.

I have the same issue...

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

@calvinjaramillo, thanks for your idea. I think, it's possible my situation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anks333 picture anks333  路  3Comments

Buzut picture Buzut  路  3Comments

greenhat616 picture greenhat616  路  3Comments

kjin picture kjin  路  3Comments

xungwoo picture xungwoo  路  3Comments