Repository navigation
Next.js: fix frozen builds on Vercel (missing config env, stale trace hashes) - #1297
Merged
Merged
Conversation
On Vercel, Next drops env from required-server-files.json, so a frozen build was read as not frozen and exited at boot. Fixes #1280.
Contributor
|
The changes in this PR will be included in the next version bump.
|
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the frozen boot detection fix, regression tests, and integration patch release entry.
- Boot detection: Recorded configs without
envnow defer to runtime initialization, while explicit non-frozen configs retain the boot failure hint. - Regression coverage: Tests cover both recorded config sources, unavailable configs, standalone and encrypted boot, and ambient frozen env handling. All 90 integration tests and package typecheck passed after building workspace dependencies.
gpt-6.1-sol | 𝕏
commit: |
Turbopack records each traced file's content hash in its .nft.json traces before we inject the prelude, so the recorded hash of [turbopack]_runtime.js was the same across builds whose frozen env differed. Next's adapter passes those hashes to the platform (Vercel's .vc-config.json fileHashes).
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the trace hash repair added since the previous review.
- Updated runtime hashes: Replaced stale NFT hashes with fingerprints of rewritten runtime files while preserving unrelated entries and hashless traces.
- Added regression coverage: Covered hash replacement, differing frozen preludes, and webpack trace preservation. The integration build, all 93 tests, typecheck, and targeted lint passed.
- Extended release notes: Included the trace hash repair in the integration patch entry.
gpt-6.1-sol | 𝕏
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.



Fixes #1280.
Boot exit on Vercel. On Vercel, Next turns on
experimental.runtimeServerDeploymentId, which writesenv: undefinedinto.next/required-server-files.json.readFrozenBuildEnvread that as "the build did not freeze" (null), so a frozen build with no varlock CLI in the function printedNOT_FROZEN_BOOT_HINTand exited before the frozen runtime prelude could run. A recorded config with noenvnow returnsundefined("can't tell"), so boot defers to the runtime prelude, which carries the frozen env. A config that hasenvwithout the frozen key still exits with the hint.Stale trace hashes. Turbopack writes a content hash for each traced file into its
.nft.jsontraces (fileHashes) before we inject the prelude into[turbopack]_runtime.js. Next's adapter passes those hashes on, and Vercel writes them into each function's.vc-config.json. The recorded hash of the runtime file was identical across builds whose frozen env differed. After injecting, we now replace that entry in every trace with a hash of the rewritten file. Vercel did not serve stale content without this fix in our tests, but nothing guarantees it won't key on those hashes.Verified on real Vercel (Next 16.4.6, Turbopack, Vercel's adapter, committed
.envfiles): two deploys of identical source with only a sensitive value changed each boot and serve their own value, both before and after the hash fix.Tests cover the Vercel config case (both
required-server-files.jsonand the standalone config), the trace hash rewrite, and related boot paths that had no coverage: standalone frozen boot, encrypted frozen env with and without_VARLOCK_ENV_KEY, missing or unparseable recorded config, and ambient__VARLOCK_ENVhandling.