Turbopack standalone with pnpm GVS omits LMDB native dependency symlink despite outputFileTracingIncludes
Link to the code that reproduces this issue
https://github.com/r34son/next-lmdb-gvs-repro
To Reproduce
- Use Node.js 22.23.4 and pnpm 12.18.0, then clone the linked reproduction.
- Run
pnpm install --frozen-lockfile. - Run
pnpm repro.
The reproduction pins Next.js 16.5.0-canary.48, the latest published npm canary when tested on November 13, 2026. It uses only public packages and a small local consumer of [email protected]; LMDB is transitive. pnpm's global virtual store is placed outside the app in a sibling directory.
The script runs a Turbopack production build, copies .next/standalone to a new temporary location, verifies that every symlink resolves within that copy, starts the copied server, and requests ESM and CJS routes that write/read an LMDB database. It removes LMDB_PREBUILD, NODE_PATH, NODE_OPTIONS, and NEXT_TEST_NATIVE_DIR from the build/server environments. There are no dependency patches, additional source symlinks, or postbuild repairs.
Relevant configuration:
export default {
output: 'standalone',
outputFileTracingRoot: process.cwd(),
turbopack: { root: process.cwd() },
experimental: { turbopackDetectGlobalVirtualStore: true },
serverExternalPackages: ['lmdb'],
outputFileTracingIncludes: {
'/**/*': [
`./node_modules/.pnpm/node_modules/@lmdb/lmdb-${process.platform}-${process.arch}/**/*`,
],
},
};
Current vs. Expected behavior
The build succeeds. The native package and binary are present in the standalone artifact, but its native dependency cannot be resolved from the relocated LMDB package. Both routes return HTTP 500:
All standalone symlinks resolve inside the copied artifact.
Native package included: true
Native binary included: true
LMDB dependency symlink included: false
Native package resolves from LMDB: MODULE_NOT_FOUND
/: HTTP 500; LMDB read/write passed: false
/cjs: HTTP 500; LMDB read/write passed: false
The runtime error is:
No native build was found for platform=darwin arch=arm64 runtime=node abi=127
attempted loading from:
<standalone>/next_additional_roots/gvs/@/lmdb/2.9.4/<hash>/node_modules/lmdb
and package: @lmdb/lmdb-darwin-arm64
Expected: both routes return HTTP 200 and successfully write/read LMDB. The dependency symlink needed by LMDB should either be traced automatically or be expressible through standard outputFileTracingIncludes within the already registered GVS root, while retaining the app-level root.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.6.0: Fri Jul 31 19:18:48 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6020
Available memory (MB): 32768
Available CPU cores: 12
Binaries:
Node: 22.23.4
npm: 10.9.9
Yarn: N/A
pnpm: 12.18.0
Relevant Packages:
next: 16.5.0-canary.48
eslint-config-next: N/A
react: 19.2.3
react-dom: 19.2.3
typescript: N/A
Next.js Config:
output: standalone
This clean reproduction was executed on macOS arm64. Linux runtime behavior has not been verified here.
Which area(s) are affected? (Select all that apply)
Module Resolution, Output, Turbopack
Which stage(s) are affected? (Select all that apply)
next build (local), Other (Deployed)
Additional context
There are two different symlinks to the platform package. The include matches the application's private hoist alias:
app/node_modules/.pnpm/node_modules/@lmdb/lmdb-darwin-arm64
That alias and all six platform-package files are present in the trace/standalone. However, this different existing dependency symlink is absent from the GVS trace metadata and copied artifact:
<GVS>/@/lmdb/2.9.4/<hash>/node_modules/@lmdb/lmdb-darwin-arm64
[email protected] creates a require function from the real LMDB package directory and resolves the platform package through that dependency link. The application's private hoist alias is not an ancestor lookup location for the relocated LMDB directory. The native binary itself is present; resolution fails before loading it.
With an app-level root, a leading ../ include that reaches the physical GVS location is rejected for leaving the root. An absolute owner-link path does not match, and lmdb/../@lmdb/... does not traverse to the physical parent after following the LMDB symlink. Additional roots currently enable dependency resolution, but the includes parser still starts from project_path and the glob walker descends through existing entries.
Source pointers: include parsing, glob normalization, include tracing.
Disclosure: this report and reproduction were prepared and submitted by Codex at the account owner's explicit request.
Would you be open to a regression test for this? I’d compare standalone output under pnpm’s global virtual store with a regular pnpm install and check that the traced LMDB dependency remains resolvable from the deployed directory.
Thanks for the clear reproduction in r34son/next-lmdb-gvs-repro.
Regarding the regression test proposed by @seragAhmed: yes, adding a regression test for this would be very valuable.
Here is what we observed inspecting the tracing pipeline:
-
Why the native dependency fails to resolve:
lmdb(vianode-gyp-build-optional-packages) requires its platform package (@lmdb/lmdb-<platform>-<arch>) starting from its physical directory inside GVS (<GVS>/@/lmdb/<version>/<hash>/node_modules/@lmdb/...). While Turbopack standalone tracing successfully copies the GVS root intonext_additional_roots/gvsand copies the native binary itself, the nested dependency symlink inside the GVS directory (.../node_modules/lmdb/node_modules/@lmdb/...) is not captured inNftAdditionalRoot.symlinks. -
Why
outputFileTracingIncludesis blocked: Incrates/next-core/src/next_config.rs(relativize_glob), user-defined include globs are strictly relative toproject_path. Any pattern attempting to traverse up into the external GVS root with../is rejected as escaping the project root. -
Regression test approach: The test in
test/production/standalone-mode/should:- Configure a pnpm project with
virtual-store-dirplaced outside the app root. - Build with
output: 'standalone'andexperimental.turbopackDetectGlobalVirtualStore: true. - Assert that the copied standalone artifact preserves the nested dependency symlink in
next_additional_roots/gvsand that requesting a route calling LMDB returns HTTP 200 withoutMODULE_NOT_FOUND.
- Configure a pnpm project with
Happy to collaborate on structuring this test or looking at how crates/next-api/src/nft.rs handles symlinks inside additional roots.