Closed scmx closed 1 year ago
This is due to https://getpino.io/#/docs/bundling.
I don't exactly know how to pass those options to Next.js (also with swc). If you figure it out send a PR!
cc @ShogunPanda
Opened a Next.js discussion about this as well https://github.com/vercel/next.js/discussions/46987
I worked around this by piping to pino-pretty instead.
npx next dev | pino-pretty
For example:
"dev": "next dev | pino-pretty -m message -i time -c"
Yes, for sure that is a good workaround.
Until somebody figures it out how to propagate bundling to Next, there's nothing we can do here.
Hi! I noticed that when using pino and pino-pretty with Next.js 13 app directory it will crash when you try to log.
Minimal reproduce repo https://github.com/scmx/next13-app-pino-pretty-worker-has-exited-minimal-reproduce
Not sure if this is a Next.js issue or a pino-pretty issue.
Error 1
error - node_modules/thread-stream/index.js (195:31) @ Worker.onWorkerExit error - uncaughtException: Error: the worker thread exited at Worker.onWorkerExit (webpack-internal:///(sc_server)/./node_modules/thread-stream/index.js:163:34) at Worker.emit (node:events:513:28) at Worker.[kOnExit] (node:internal/worker:287:10) at Worker..onexit (node:internal/worker:202:20) at Worker.callbackTrampoline (node:internal/async_hooks:130:17) null
Error 2
error - uncaughtException: Error: Cannot find module 'next13-app-pino-pretty/.next/server/app/lib/worker.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15) at Function.Module._load (node:internal/modules/cjs/loader:833:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at MessagePort. (node:internal/main/worker_thread:197:24) at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:736:20) at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28) { code: 'MODULE_NOT_FOUND', requireStack: [] }
The error doesn't show up when disabling the pino-pretty transport.