-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
Summary: Discussions in this issue have diverged a bit, and there are mainly two cases:
- Turbopack + non-Vercel deployment. Broken since v16.0.3 due to Turbopack starts to trace worker_threads (fixed [Turbopack Nextjs 16]: Pino - Worker thread cannot find module 'real-require' #84766).
- Errors (include but not limited to):
- Workaround:
- Switch back to Webpack.
next build --webpack - Or add
pino,thread-streamand related pino transport target packages toserverExternalPackages, you might also need to addthread-streamas a dependency explicitly.
- Switch back to Webpack.
- Fixed: since v16.1.0-canary.16 by Turbopack: write symlinks to access transitive
serverExternalPackages#86375 and Add pino-related packages to server-external-packages #86884
- Turbopack + Vercel deployement. This is the original case of this issue. Turbopack never works in this setup, [Turbopack Nextjs 16]: Pino - Worker thread cannot find module 'real-require' #84766 was fixed in v16.0.3, and now [Turbopack Nextjs 16]: Pino - Cannot find module './transport-stream' #86099 is waiting for a fix. The fixes above doesn't work for this case (see [Turbopack Nextjs 16]: Pino - Cannot find module './transport-stream' #86099 (comment)). The only workaround is to use Webpack
next build --webpackwithserverExternalPackages, see Notes below.
Notes:
From comment9
Pino is way too dynamic for Turbopack to be able to figure out all required files automatically: pinojs/pino@7dd79a3/lib/transport.js#L94
Pino itself has a documentation that talks about bundling, and there were already problems since Webpack + Vercel deployment, see comment10.
Also for in−depth details: pinojs/thread-stream#184
Link to the code that reproduces this issue
To Reproduce
- Deploy the code to Vercel
- Visit /api/log
- Check the log of the Vercel deployment
Current vs. Expected behavior
Current behavior
With Turbopack in NextJs v16, Pino worker thread throws the following error:
Uncaught Exception: Error: Cannot find module './transport-stream'
Require stack:
- /var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1420:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1058:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1063:22)
at Module._load (node:internal/modules/cjs/loader:1226:37)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
at Module.require (node:internal/modules/cjs/loader:1503:12)
at a (/opt/rust/bytecode.js:2:1094)
at Object.<anonymous> (/var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js:7:36)
at Module.<anonymous> (/opt/rust/bytecode.js:2:1435)
Expected behavior
Pino worker thread works without any exception, which is the behavior of using
WebPack.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025
Available memory (MB): 15839
Available CPU cores: 20
Binaries:
Node: 24.11.1
npm: 11.6.2
Yarn: N/A
pnpm: 10.24.0
Relevant Packages:
next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
eslint-config-next: N/A
react: 19.2.1
react-dom: 19.2.1
typescript: 5.9.3
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
@mischnic This is a follow up of #84766. It seems that with multiple targets, the pino/lib/worker.js is used and not traced by Turbopack properly. I have updated the reproduction code to trigger the new error.