Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c8cf55f4
Unverified
Commit
c8cf55f4
authored
Aug 25, 2025
by
Niklas Mischkulnig
Committed by
GitHub
Aug 25, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: fix invalid NFT entry with file behind symlink (#83013)
parent
c240df08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
40 deletions
+86
-40
nft_json.rs
crates/next-api/src/nft_json.rs
+33
-0
mod.rs
turbopack/crates/turbopack-core/src/resolve/mod.rs
+53
-40
No files found.
crates/next-api/src/nft_json.rs
View file @
c8cf55f4
...
@@ -231,6 +231,38 @@ impl Asset for NftJsonAsset {
...
@@ -231,6 +231,38 @@ impl Asset for NftJsonAsset {
continue
;
continue
;
}
}
#[cfg(debug_assertions)]
{
// Verify that we there are no entries where a file is created inside of a symlink,
// as this can result in invalid ZIP files and deployment failures.
// For example
// node_modules/.pnpm/node_modules/@libsql/client/package.json
// where
// node_modules/.pnpm/node_modules/@libsql/client is a symlink
let
mut
current_path
=
referenced_chunk_path
.parent
();
loop
{
use
turbo_tasks_fs
::
FileSystemEntryType
;
if
current_path
.is_root
()
{
break
;
}
if
matches!
(
&*
current_path
.get_type
()
.await
?
,
FileSystemEntryType
::
Symlink
)
{
bail!
(
"Encountered file inside of symlink in NFT list: {} is a symlink, but
\
{} was created inside of it"
,
current_path
.value_to_string
()
.await
?
,
referenced_chunk_path
.value_to_string
()
.await
?
);
}
current_path
=
current_path
.parent
();
}
}
let
Some
(
specifier
)
=
get_output_specifier
(
let
Some
(
specifier
)
=
get_output_specifier
(
&
referenced_chunk_path
,
&
referenced_chunk_path
,
&
ident_folder
,
&
ident_folder
,
...
@@ -241,6 +273,7 @@ impl Asset for NftJsonAsset {
...
@@ -241,6 +273,7 @@ impl Asset for NftJsonAsset {
else
{
else
{
continue
;
continue
;
};
};
result
.insert
(
specifier
);
result
.insert
(
specifier
);
}
}
...
...
turbopack/crates/turbopack-core/src/resolve/mod.rs
View file @
c8cf55f4
...
@@ -2133,58 +2133,70 @@ async fn resolve_into_folder(
...
@@ -2133,58 +2133,70 @@ async fn resolve_into_folder(
package_path
:
FileSystemPath
,
package_path
:
FileSystemPath
,
options
:
Vc
<
ResolveOptions
>
,
options
:
Vc
<
ResolveOptions
>
,
)
->
Result
<
Vc
<
ResolveResult
>>
{
)
->
Result
<
Vc
<
ResolveResult
>>
{
let
package_json_path
=
package_path
.join
(
"package.json"
)
?
;
let
options_value
=
options
.await
?
;
let
options_value
=
options
.await
?
;
for
resolve_into_package
in
options_value
.into_package
.iter
()
{
let
mut
affecting_sources
=
vec!
[];
match
resolve_into_package
{
if
let
Some
(
package_json_path
)
=
ResolveIntoPackage
::
MainField
{
field
:
name
}
=>
{
exists
(
&
package_path
.join
(
"package.json"
)
?
,
&
mut
affecting_sources
)
.await
?
if
let
Some
(
package_json
)
=
{
&*
read_package_json
(
Vc
::
upcast
(
FileSource
::
new
(
package_json_path
.clone
())))
for
resolve_into_package
in
options_value
.into_package
.iter
()
{
.await
?
match
resolve_into_package
{
&&
let
Some
(
field_value
)
=
package_json
[
name
.as_str
()]
.as_str
()
ResolveIntoPackage
::
MainField
{
field
:
name
}
=>
{
{
if
let
Some
(
package_json
)
=
let
normalized_request
=
RcStr
::
from
(
normalize_request
(
field_value
));
&*
read_package_json
(
Vc
::
upcast
(
FileSource
::
new
(
package_json_path
.clone
())))
if
normalized_request
.is_empty
()
.await
?
||
&*
normalized_request
==
"."
&&
let
Some
(
field_value
)
=
package_json
[
name
.as_str
()]
.as_str
()
||
&*
normalized_request
==
"./"
{
{
continue
;
let
normalized_request
=
RcStr
::
from
(
normalize_request
(
field_value
));
}
if
normalized_request
.is_empty
()
let
request
=
Request
::
parse_string
(
normalized_request
);
||
&*
normalized_request
==
"."
||
&*
normalized_request
==
"./"
// main field will always resolve not fully specified
{
let
options
=
if
options_value
.fully_specified
{
continue
;
options
.with_fully_specified
(
false
)
.resolve
()
.await
?
}
}
else
{
let
request
=
Request
::
parse_string
(
normalized_request
);
options
// main field will always resolve not fully specified
let
options
=
if
options_value
.fully_specified
{
options
.with_fully_specified
(
false
)
.resolve
()
.await
?
}
else
{
options
};
let
result
=
&*
resolve_internal_inline
(
package_path
.clone
(),
request
,
options
)
.await
?
.await
?
;
// we are not that strict when a main field fails to resolve
// we continue to try other alternatives
if
!
result
.is_unresolvable_ref
()
{
let
mut
result
:
ResolveResultBuilder
=
result
.with_request_ref
(
rcstr!
(
"."
))
.into
();
result
.affecting_sources
.push
(
ResolvedVc
::
upcast
(
FileSource
::
new
(
package_json_path
)
.to_resolved
()
.await
?
,
));
result
.affecting_sources
.extend
(
affecting_sources
);
return
Ok
(
ResolveResult
::
from
(
result
)
.cell
());
}
};
};
let
result
=
&*
resolve_internal_inline
(
package_path
.clone
(),
request
,
options
)
}
.await
?
ResolveIntoPackage
::
ExportsField
{
..
}
=>
{}
.await
?
;
// we are not that strict when a main field fails to resolve
// we continue to try other alternatives
if
!
result
.is_unresolvable_ref
()
{
let
mut
result
:
ResolveResultBuilder
=
result
.with_request_ref
(
rcstr!
(
"."
))
.into
();
result
.affecting_sources
.push
(
ResolvedVc
::
upcast
(
FileSource
::
new
(
package_json_path
)
.to_resolved
()
.await
?
,
));
return
Ok
(
ResolveResult
::
from
(
result
)
.cell
());
}
};
}
}
ResolveIntoPackage
::
ExportsField
{
..
}
=>
{}
}
}
}
}
if
options_value
.fully_specified
{
if
options_value
.fully_specified
{
return
Ok
(
*
ResolveResult
::
unresolvable
());
return
Ok
(
*
ResolveResult
::
unresolvable_with_affecting_sources
(
affecting_sources
,
));
}
}
// fall back to dir/index.[js,ts,...]
// fall back to dir/index.[js,ts,...]
let
pattern
=
match
&
options_value
.default_files
[
..
]
{
let
pattern
=
match
&
options_value
.default_files
[
..
]
{
[]
=>
return
Ok
(
*
ResolveResult
::
unresolvable
()),
[]
=>
{
return
Ok
(
*
ResolveResult
::
unresolvable_with_affecting_sources
(
affecting_sources
,
));
}
[
file
]
=>
Pattern
::
Constant
(
format!
(
"./{file}"
)
.into
()),
[
file
]
=>
Pattern
::
Constant
(
format!
(
"./{file}"
)
.into
()),
files
=>
Pattern
::
Alternatives
(
files
=>
Pattern
::
Alternatives
(
files
files
...
@@ -2199,7 +2211,8 @@ async fn resolve_into_folder(
...
@@ -2199,7 +2211,8 @@ async fn resolve_into_folder(
Ok
(
Ok
(
resolve_internal_inline
(
package_path
.clone
(),
request
,
options
)
resolve_internal_inline
(
package_path
.clone
(),
request
,
options
)
.await
?
.await
?
.with_request
(
rcstr!
(
"."
)),
.with_request
(
rcstr!
(
"."
))
.with_affecting_sources
(
ResolvedVc
::
deref_vec
(
affecting_sources
)),
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment