pinojs / pino-socket

🌲 A transport for sending pino logs to network sockets
43 stars 14 forks source link

Emit a socketClose event instead of defining onSocketClose callback #82

Closed ggrossetie closed 2 years ago

ggrossetie commented 2 years ago

As mentioned in https://github.com/pinojs/pino-socket/issues/77, onSocketClose callback function cannot be serialized across worker thread boundaries.

I think it would be better to emit an event on the stream with an optional Error:

 outputStream.emit('socketClose', hadError && socketError)

To be consistent, we should probably do the same when we cannot reconnect:

retry.on('fail', (err) => {
  outputStream.emit('reconnectFailure', err) // or socketReconnectFailure?
})
ggrossetie commented 2 years ago

Fixed in https://github.com/pinojs/pino-socket/commit/53250e6e764240f0adba38d075db2e93dfdd7056