I'm trying to understand how a worker thread is passing an error back to the main Pino process through the worker message bus. In the code below there is a transport with an internal EventEmitter that emits an unhandled error event. Yet, somehow, we can attach an .on('error') listener to the transport and handle that emitted event. How does this work?
$ nodemon -r esm -e yaml,js,json index | pino-pg --connectionUrl postgres://xxx:firstname.lastname@example.org:5432/easycollab --table test.logs --column log
SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)