winstonjs / winston-syslog

A syslog transport for winston
http://github.com/winstonjs/winston-syslog
MIT License
138 stars 119 forks source link

Error healthCheck(dgram) #161

Closed Apollon77 closed 2 years ago

Apollon77 commented 3 years ago

We use Sentry in our project and also wniston-syslog, some users have this problem:

https://sentry.iobroker.net/share/issue/0fe0c0c9a1f94a12a06676ee2195f5ef/

Error: Not running
  File "dgram.js", line 899, col 11, in healthCheck
  File "dgram.js", line 624, col 3, in Socket.send
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 166, col 17, in IoSysLog._sendChunk
    this.socket.send(
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 148, col 14, in IoSysLog.chunkMessage
    this._sendChunk(
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 233, col 16, in sendDgram
    this.chunkMessage(buffer, onError);
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 253, col 9, in null.<anonymous>
    sendDgram();
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 331, col 11, in IoSysLog.connect
    ? callback(null)
  File "/opt/iobroker/node_modules/winston-syslog/lib/winston-syslog.js", line 203, col 10, in IoSysLog.log
    this.connect(err => {
  File "/opt/iobroker/node_modules/iobroker.js-controller/lib/logger.js", line 53, col 15, in IoSysLog.log
    super.log(ioInfo, callback);
  File "/opt/iobroker/node_modules/winston-transport/index.js", line 103, col 17, in IoSysLog._write
    return this.log(transformed, callback);

As fix I would propose a try/catch around https://github.com/winstonjs/winston-syslog/blob/4b74b36089a24e397e8e311e939a6e478afc8319/lib/winston-syslog.js#L166-L173 and calling the callback in case of an exception ... or?!