Fix build crash when outputFileTracingIncludes matches a symlink - #96999
Draft
sokra wants to merge 1 commit into
Draft
Fix build crash when outputFileTracingIncludes matches a symlink#96999sokra wants to merge 1 commit into
sokra wants to merge 1 commit into
Conversation
A glob in `outputFileTracingIncludes` that wholly matches a symlink pointing
at a directory made the build fail with a fatal internal error:
Error [TurbopackInternalError]: reading file ".../.claude/skills/ink"
Caused by: Is a directory (os error 21)
`read_glob` reports a symlink (also one that points at a directory) as
`DirectoryEntry::Symlink`, so `get_glob_includes` collected it as a file and
`NftJsonAsset` then hashed it with `path.read()`, which follows the link and
hits `EISDIR`.
Symlinks are now hashed by their link content (target + link type) instead of
the content of the file they point at. That is also the correct hash: consumers
of the nft json re-create a symlink entry as a symlink (see `copyTracedFiles`)
rather than copying the resolved file. The symlink itself stays in the trace,
it is neither expanded nor resolved.
Include entries that have no content to hash (a path that disappeared, a
symlink escaping the filesystem root, an unreadable file) are now reported as a
warning issue and skipped, instead of aborting the whole build with an internal
error.
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Contributor
Tests PassedCommit: 488ce12 |
Contributor
Stats from current PRWarning No stats were collected for Webpack because its stats job did not complete (it failed, was cancelled, or timed out). The results below only cover the bundlers that finished. ✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: 488ce12 |
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.
What?
A glob in
outputFileTracingIncludesthat wholly matches a symlink pointing at a directory made Turbopack builds fail with a fatal internal error instead of completing:Included symlinks are now hashed by their link content (target + link type) instead of the content of whatever they point at, and they stay in the trace as the symlink itself rather than being resolved or expanded. Include entries that have no content to hash (a path that disappeared, a symlink escaping the project root, an unreadable file) are now reported as a build issue and skipped instead of aborting the whole build.
Why?
get_glob_includesalready returned symlinks (including ones pointing at a directory) as trace entries, butNftJsonAssethashed them by reading through the link, which fails outright on a directory target. Reading through the link was also the wrong operation in general:copyTracedFilesrecreates a traced symlink as a symlink (fs.readlink+fs.symlink), never by copying the resolved file's bytes, so the link's own content is what should be hashed.How?
LinkContent::hashinturbo-tasks-fs, mirroring the existingFileContent::hash.hash_traced_includeinnext-api, dispatching by entry type: file → content hash, symlink → link hash, directory → skip (existing behavior, unchanged), anything else/unreadable → emit a newUnhashableTracedFileIssuewarning and skip.build-trace-extra-entries-turboe2e fixture with a symlink-to-directory match and asserted it shows up in the.nft.json.Test plan
cargo test -p next-api/-p turbo-tasks-fscargo clippy --all-targets/cargo fmt --checkon the touched cratestest/production/build-trace-extra-entries-turboe2e, both Turbopack and webpack modes