/next13-app-pino-pretty-worker-has-exited-minimal-reproduce

Minimal reproduce of pino-pretty crash with Next 13 app directory.

Primary LanguageCSS

Minimal reproduce of pino-pretty crash with Next 13 app directory

Pino is a json logging library that can be used with for example Next.js. There's an extension called pino-pretty that will output it nicely for development. These work fine with Next 12 and Next 13 without app folder. But when using app folder and pino-pretty you currently get a crash like below. This repo aims to reproduce that error.

pino({ transport: { target: 'pino-pretty' } }) doesn't work pino() works

Minimal reproduce of error

npm i && npm run dev

url works? feature
http://localhost:3001 app page
http://localhost:3001/api/hello app route
http://localhost:3001/old old pages
http://localhost:3001?pretty app page
http://localhost:3001/api/hello?pretty app route
http://localhost:3001/old?pretty old pages

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: [] }

A workaround

You can pipe to pino-pretty instead.

npx next dev | pino-pretty

For example:

"dev": "next dev | pino-pretty -m message -i time -c"


This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.