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
99b5c803
Unverified
Commit
99b5c803
authored
Sep 03, 2026
by
Tim Neutkens
Committed by
GitHub
Sep 03, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HMR subscription initialization race
parent
08c7ab6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
project.rs
crates/next-api/src/project.rs
+6
-7
hot-reloader-turbopack.ts
packages/next/src/server/dev/hot-reloader-turbopack.ts
+21
-2
No files found.
crates/next-api/src/project.rs
View file @
99b5c803
...
...
@@ -2558,13 +2558,12 @@ impl Project {
}
let
version_op
=
hmr_version_operation
(
self
,
chunk_name
.clone
(),
target
);
// INVALIDATION: This is intentionally untracked to avoid invalidating this
// function completely. We want to initialize the VersionState with the
// first seen version of the session.
let
initial_version
=
version_op
.read_trait_strongly_consistent
()
.untracked
()
.await
?
;
// INVALIDATION: This is intentionally eventual and untracked. The baseline
// must remain the first version observed when the subscription starts. A
// strongly consistent read can restart after an invalidation and instead
// adopt the post-edit version. The following update then appears empty even
// though an already-loaded browser still has the pre-edit output.
let
initial_version
=
version_op
.connect
()
.into_trait_ref
()
.untracked
()
.await
?
;
if
tracing
::
enabled!
(
target
:
"turbopack_hmr_diagnostics"
,
tracing
::
Level
::
INFO
)
{
let
version_id
=
TraitRef
::
cell
(
initial_version
.clone
())
.id
()
...
...
packages/next/src/server/dev/hot-reloader-turbopack.ts
View file @
99b5c803
...
...
@@ -1050,8 +1050,10 @@ export async function createHotReloaderTurbopack(
state
.
subscriptions
.
set
(
id
,
subscription
)
hmrDiagnostic
(
'client-subscription-created'
,
{
id
})
// The subscription will always emit once, which is the initial
// computation. This is not a change, so swallow it.
// The subscription always emits once for its initial computation. Usually
// that is issues-only, but an edit can land while the baseline is being
// established. In that case the first emission is already a real update
// and must be forwarded to the browser.
try
{
const
initial
=
await
subscription
.
next
()
hmrDiagnostic
(
'client-subscription-initial'
,
{
...
...
@@ -1059,6 +1061,23 @@ export async function createHotReloaderTurbopack(
done
:
initial
.
done
,
updateType
:
initial
.
value
?.
type
,
})
if
(
initial
.
done
)
{
return
}
const
initialData
=
initial
.
value
processIssues
(
state
.
clientIssues
,
key
,
initialData
,
false
,
true
)
if
(
initialData
.
type
!==
'issues'
)
{
hmrDiagnostic
(
'client-subscription-initial-update'
,
{
id
,
updateType
:
initialData
.
type
,
instructionType
:
'instruction'
in
initialData
?
(
initialData
.
instruction
as
{
type
?:
string
}
|
undefined
)?.
type
:
undefined
,
})
sendTurbopackMessage
(
initialData
as
TurbopackUpdate
)
}
for
await
(
const
data
of
subscription
)
{
hmrDiagnostic
(
'client-subscription-update'
,
{
...
...
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