logtail-js
logtail-js copied to clipboard
@logtail/pino in nextjs
When I follow this setup
const token = '$SOURCE_TOKEN';
const pino = require('pino');
const transport = pino.transport({
target: "@logtail/pino",
options: { sourceToken: token }
});
const logger = pino(transport);
I get the error below nonstop and the server crashes
⨯ node_modules/thread-stream/index.js (235:18) @ ThreadStream.write
⨯ uncaughtException: Error: the worker has exited
at ThreadStream.write (webpack-internal:///(rsc)/./node_modules/thread-stream/index.js:199:25)
at Pino.write (webpack-internal:///(rsc)/./node_modules/pino/lib/proto.js:163:12)
at Pino.LOG (webpack-internal:///(rsc)/./node_modules/pino/lib/tools.js:39:27)
at Pino.eval [as fatal] (webpack-internal:///(rsc)/./node_modules/pino/lib/levels.js:17:22)
at process.eval (webpack-internal:///(rsc)/./src/logging.ts:53:16)
at process.emit (node:events:529:35)
at process._fatalException (node:internal/process/execution:158:25)
null
Error: the worker has exited
at ThreadStream.write (webpack-internal:///(rsc)/./node_modules/thread-stream/index.js:199:25)
at Pino.write (webpack-internal:///(rsc)/./node_modules/pino/lib/proto.js:163:12)
at Pino.LOG (webpack-internal:///(rsc)/./node_modules/pino/lib/tools.js:39:27)
at Pino.eval [as fatal] (webpack-internal:///(rsc)/./node_modules/pino/lib/levels.js:17:22)
at process.eval (webpack-internal:///(rsc)/./src/logging.ts:53:16)
at process.emit (node:events:529:35)
at process._fatalException (node:internal/process/execution:158:25)
What would be the best way to stream pino logs to logtail?
Hi @TranHung92,
Thank you for reaching out! I hope you're doing great!
Could you share more details about your setup? 🙏 What NextJS version are you using? Are you using the latest @logtail/pino version?
Thanks again for raising this!
Hi @curusarn I'm using nextjs 14.1.0 with app router setup and @logtail/[email protected]
@curusarn any update on this?