AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack 16.2.0 Standalone Output Fails To Resolve ServerExternalPackages In Docker

Next.js 16.2.0 with Turbopack and output: 'standalone' generates hashed external modules in .next/node_modules that are not correctly resolved at runtime in Docker, causing server startup failures for packages like @opentelemetry/instrumentation, redis, lru-cache, and pino.

highConfidence 85%Next.jsServer ActionsHydrationAffected V16.2.0

Origin Analysis

Turbopack externalizes serverExternalPackages into hashed module names (e.g., @opentelemetry/instrumentation-6d4cbf8d0d66c550) placed in .next/node_modules, but the standalone output's runtime module resolution does not properly include or map that directory. The generated server chunks reference these hashed modules via externalRequire, but the require stack's base path expects them relative to .next, and the Dockerfile's typical copy commands do not include .next/node_modules; even when copied, the module is still not found due to a path/base mismatch in Turbopack's runtime.
1. Clone https://github.com/Netail/repro-next-turbopack-standalone-external-packages 2. Run pnpm install 3. Run sh repro.sh to build and create Docker image 4. Run the test-app:0.1.0 Docker image 5. Observe logs show: Failed to prepare server Error: An error occurred while loading instrumentation hook: Failed to load external module @opentelemetry/instrumentation-... Cannot find module 6. Try uncommenting Dockerfile line 10 to copy .next/node_modules; same error persists.

Fixing Code Block

Edge Case Audit

Disabling Turbopack may increase build times and could expose webpack-specific bundling differences. It also disables Turbopack for development if `next dev` is used. Rollback: remove `turbopack: false` and rebuild after upgrading to a fixed Next.js version. Test all server-external packages and instrumentation hooks after switching.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state