Repository navigation
fix(builder): materialize traced packages during standalone relocation - #194
Merged
Merged
Conversation
antoinetoussaint-byte
requested a review
from AntoineToussaint
as a code owner
October 29, 2026 20:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (measured on the Blue cell)
The saas frontend built by the released agent v0.0.170 fails at start, so every page answers 500:
Turbopack emits hashed package aliases for traced server dependencies (here Sentry's
require-in-the-middle) as relative symlinks under.next/standalone/.next/node_modules/<name>-<hash> -> ../../node_modules/<name>. The standalone relocation intemplates/builder/context/next-build.cjs.tmplcopied the standalone tree withfs.cpSync(..., { dereference: true }), which did not materialize that aliased package into the runtime, so the runtime image cannot resolve it once the build stage's source tree is gone.Fix
Relocation copies with
fs.promises.cp(..., { recursive: true, dereference: true })for the standalone tree,public/static assets and export output, which materializes the traced alias as a real directory in the runtime. Cherry-picked froma3150419alone (its parent was a dependabot gomod branch; that bump is not part of this PR,go.mod/go.sumare main's).Classification: fix, at the owning place: the standalone relocation helper is this agent's build recipe. Reused: the existing helper and Node's
fs.promises.cp; no new mechanism, no change to core or the CLI.Tests
TestNextTurbopackStandaloneRelocation(next_output_test.go): realnext build(Next 16.4.1 +@sentry/nextjs10.75.2, Turbopack), asserts the hashedrequire-in-the-middle-*alias exists, relocates it, withholds the source tree, startsnode server.jsfrom the runtime, requiresGET /auth/callback= 200, and asserts the alias in the runtime is a materialized directory with identical bytes.GOWORK=off, Node v24.22.1, Docker running):go build ./...,go vet ./...,go mod tidy -diff: clean.go test ./...: ok (131 PASS, 0 FAIL;TestNextjsLifecycle_Matrixnative/nix/docker all ran and passed).CODEFLY_TEST_NEXT_BUILD=1 go test -run '^TestNext(ConfiguredStandaloneOutput|ExportRejectsStaleOutput|TurbopackStandaloneRelocation)$': PASS (TurbopackStandaloneRelocation 24.6s:GET /auth/callback200 with source withheld, aliasrequire-in-the-middle-2ca7b9c2766f317ematerialized; ConfiguredStandaloneOutput default + custom_nested; ExportRejectsStaleOutput default + custom).fs.cpSync,TestNextTurbopackStandaloneRelocationfails withexpected: 200, actual: 500and the server log shows the Blue error verbatim (Failed to load external module require-in-the-middle-2ca7b9c2766f317e ... Cannot find module). Same alias hash as Blue.Not verified
go test ./...:TestCreateToRun(needsCODEFLY_TEST_RUNNER=1),TestManifestGuardRender(manifest-guard workflow),TestNativeAgentOwnershipLifecycle(needs built-artifact qualification env),TestSelectedConsumerBuildProjection(needs a consumer source). Theciinputs_conformanceandproto_companion_requiredtagged suites were not run (the change does not touch discovery or Sync).🤖 Generated with Claude Code