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
10463c73
Unverified
Commit
10463c73
authored
Oct 20, 2026
by
Luke Sandberg
Committed by
GitHub
Oct 20, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turbopack: keep env and preview props invalidations key-granular on warm start (#100425)
parent
3cb82f9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
10 deletions
+39
-10
project.rs
crates/next-api/src/project.rs
+12
-7
lib.rs
turbopack/crates/turbo-tasks-env/src/lib.rs
+27
-3
No files found.
crates/next-api/src/project.rs
View file @
10463c73
...
...
@@ -133,6 +133,10 @@ pub struct DraftModeOptions {
pub
preview_mode_signing_key
:
RcStr
,
}
/// A cell holding [`DraftModeOptions`], some of these change in every session.
#[turbo_tasks
::
value(transparent)]
struct
DraftModeOptionsValue
(
DraftModeOptions
);
#[turbo_tasks
::
task_input]
#[derive(
Debug,
...
...
@@ -973,7 +977,7 @@ impl ProjectContainer {
versioned_content_map
:
self
.versioned_content_map
,
build_id
,
encryption_key
,
preview_props
,
preview_props
:
ResolvedVc
::
cell
(
preview_props
)
,
no_mangling
,
write_routes_hashes_manifest
,
current_node_js_version
,
...
...
@@ -1063,7 +1067,7 @@ pub struct Project {
encryption_key
:
RcStr
,
preview_props
:
DraftModeOptions
,
preview_props
:
ResolvedVc
<
DraftModeOptionsValue
>
,
/// When the code is minified, this opts out of the default mangling of
/// local names for variables, functions etc., which can be useful for
...
...
@@ -1680,15 +1684,16 @@ impl Project {
}
#[turbo_tasks
::
function]
pub
(
super
)
fn
edge_env
(
&
self
)
->
Vc
<
EnvMap
>
{
pub
(
super
)
async
fn
edge_env
(
&
self
)
->
Result
<
Vc
<
EnvMap
>>
{
let
preview_props
=
self
.preview_props.await
?
;
let
edge_env
=
fxindexmap!
{
rcstr!
(
"__NEXT_BUILD_ID"
)
=>
self
.build_id
.clone
(),
rcstr!
(
"NEXT_SERVER_ACTIONS_ENCRYPTION_KEY"
)
=>
self
.encryption_key
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_ID"
)
=>
self
.
preview_props.preview_mode_id
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY"
)
=>
self
.
preview_props.preview_mode_encryption_key
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_SIGNING_KEY"
)
=>
self
.
preview_props.preview_mode_signing_key
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_ID"
)
=>
preview_props
.preview_mode_id
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_ENCRYPTION_KEY"
)
=>
preview_props
.preview_mode_encryption_key
.clone
(),
rcstr!
(
"__NEXT_PREVIEW_MODE_SIGNING_KEY"
)
=>
preview_props
.preview_mode_signing_key
.clone
(),
};
Vc
::
cell
(
edge_env
)
Ok
(
Vc
::
cell
(
edge_env
)
)
}
#[turbo_tasks
::
function]
...
...
turbopack/crates/turbo-tasks-env/src/lib.rs
View file @
10463c73
...
...
@@ -30,9 +30,28 @@ impl TransientEnvMap {
}
}
#[turbo_tasks
::
value(transparent)]
/// A map of environment variables.
#[turbo_tasks
::
value(transparent,
cell
=
"keyed"
)]
pub
struct
EnvMap
(
#
[
bincode
(
with
=
"turbo_bincode::indexmap"
)]
FxIndexMap
<
RcStr
,
RcStr
>
);
/// An [`EnvMap`] with uppercased keys, used for key-granular case-insensitive lookups.
///
/// Unlike [`TransientEnvMap`] this is persisted: it only contains values that are already
/// persisted in the [`EnvMap`] it's derived from. Keyed comparison needs the previous content, so
/// persisting it keeps a dirty recomputation after a warm restore from invalidating every reader.
#[turbo_tasks
::
value(transparent,
cell
=
"keyed"
)]
struct
UppercaseEnvMap
(
#
[
bincode
(
with
=
"turbo_bincode::indexmap"
)]
FxIndexMap
<
RcStr
,
RcStr
>
);
#[turbo_tasks
::
function]
async
fn
uppercase_env_map
(
map
:
Vc
<
EnvMap
>
)
->
Result
<
Vc
<
UppercaseEnvMap
>>
{
let
map
=
&*
map
.await
?
;
let
mut
new
=
FxIndexMap
::
with_capacity_and_hasher
(
map
.len
(),
Default
::
default
());
for
(
k
,
v
)
in
map
{
new
.insert
(
k
.to_uppercase
()
.into
(),
v
.clone
());
}
Ok
(
Vc
::
cell
(
new
))
}
#[turbo_tasks
::
value_impl]
impl
EnvMap
{
#[turbo_tasks
::
function]
...
...
@@ -48,9 +67,14 @@ impl ProcessEnv for EnvMap {
Ok
(
Vc
::
cell
((
*
self
.await
?
)
.clone
()))
}
/// Reads a single env variable, ignoring casing. Only depends on the requested variable, so
/// it isn't invalidated when other variables change.
#[turbo_tasks
::
function]
fn
read
(
self
:
Vc
<
Self
>
,
name
:
RcStr
)
->
Vc
<
Option
<
RcStr
>>
{
case_insensitive_read
(
self
.read_all
(),
name
)
async
fn
read
(
self
:
Vc
<
Self
>
,
name
:
RcStr
)
->
Result
<
Vc
<
Option
<
RcStr
>>>
{
let
value
=
uppercase_env_map
(
self
)
.get
(
name
.to_uppercase
()
.as_str
())
.await
?
;
Ok
(
Vc
::
cell
(
value
.as_deref
()
.cloned
()))
}
}
...
...
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