Message and stack trace is not properly logged for Error objects.
Easiest way to reproduce this is to create a new Next.js project, add next-logger and start the project with NODE_OPTIONS='-r next-logger' next start which should yield an error about missing production build. Example repo here.
Output:
$ npm start
> next-logger-example@0.1.0 start
> NODE_OPTIONS='-r next-logger' next start
{"level":30,"time":1626264420488,"pid":18313,"hostname":"MacBook-Pro","name":"next.js","prefix":"ready","msg":"started server on 0.0.0.0:3000, url: http://localhost:3000"}
{"level":50,"time":1626264420813,"pid":18313,"hostname":"MacBook-Pro","name":"next.js","prefix":"error","msg":{}}
Throwing inside Next.js application also gives no information about the error:
$ npm run dev
> next-logger-example@0.1.0 dev
> NODE_OPTIONS='-r next-logger' next dev | pino-pretty
[1626264357128] INFO (next.js/18243 on MacBook-Pro): started server on 0.0.0.0:3000, url: http://localhost:3000
prefix: "ready"
[1626264357307] INFO (next.js/18243 on MacBook-Pro): Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
prefix: "info"
[1626264359451] INFO (next.js/18243 on MacBook-Pro): compiled successfully
prefix: "event"
[1626264359777] INFO (next.js/18243 on MacBook-Pro): build page: /next/dist/pages/_error
prefix: "event"
[1626264359778] INFO (next.js/18243 on MacBook-Pro): compiling...
prefix: "wait"
[1626264360380] INFO (next.js/18243 on MacBook-Pro): compiled successfully
prefix: "event"
[1626264367326] INFO (next.js/18243 on MacBook-Pro): build page: /
prefix: "event"
[1626264367327] INFO (next.js/18243 on MacBook-Pro): compiling...
prefix: "wait"
[1626264369956] INFO (next.js/18243 on MacBook-Pro): compiled successfully
prefix: "event"
[1626264370075] ERROR (next.js/18243 on MacBook-Pro):
prefix: "error"
msg: {}
As seen from the output msg object remains empty in both cases.
Message and stack trace is not properly logged for
Error
objects.Easiest way to reproduce this is to create a new Next.js project, add
next-logger
and start the project withNODE_OPTIONS='-r next-logger' next start
which should yield an error about missing production build. Example repo here.Output:
Throwing inside Next.js application also gives no information about the error:
As seen from the output
msg
object remains empty in both cases.