Closed ikovac closed 2 years ago
You need to close/wait for your stream to close by passing a close()
function to https://github.com/pinojs/pino-abstract-transport#buildfn-opts--stream.
Thank you for your answer! If I understood right, I need to emit an event before calling the next callback like this:
this.#cloudWatchLogs.createLogGroup({ logGroupName: this.#logGroupName }, (err, data) => {
console.log('HERE 2!!!');
if (err) console.log('err: ', err);
this.emit('close');
next();
}
and then pass close
function to the build options like this:
close(err, cb) {
stream.on('close', () => {
console.log('Stream is closed');
cb();
})
}
Right?
I did this, and it seems to work now, but it doesn't print the Stream is closed
message. It looks like strem.on('close')
never get called.
That's expected. console.log()
in worker threads is asynchronous and go into the main thread event loop. However in your example the main event loop has already shut down, so you can't log anything. You can use process._rawDebug()
to actually print something.
Thank you soo much! 🙇
Are you going to publish this in a module?
Yeah, I can do that as soon I finish it. I will post a link here in the comment 😉
Send a PR, we list known transports in the docs.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Hello 👋 , I am trying to make custom cloudwatch transport and this is my code:
cloudwatch-transport.cjs
index.js
But worker thread is closed before
_write
methodnext
callback gets called.HERE 1!!!
gets printed, butHERE 2!!!
doesn't.If I put a log statement inside setInterval it works because the worker thread is not closed:
Am I doing something wrong? Thanks in advance! 🙌