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
bca423c5
Commit
bca423c5
authored
Feb 11, 2026
by
Jimmy Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: restore app-page stream helper and trim runInContext wrappers
parent
3e1ece70
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
25 deletions
+22
-25
app-render-prerender-utils.ts
.../next/src/server/app-render/app-render-prerender-utils.ts
+8
-8
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+14
-17
No files found.
packages/next/src/server/app-render/app-render-prerender-utils.ts
View file @
bca423c5
...
...
@@ -121,14 +121,14 @@ export class ReactServerResult {
this
.
_stream
=
tee
[
0
]
return
tee
[
1
]
}
else
if
(
process
.
env
.
NEXT_RUNTIME
!==
'edge'
)
{
return
this
.
_runInContext
(()
=>
{
const
[
primary
,
secondary
]
=
teeNodeReadable
(
this
.
_stream
as
NodeReadable
,
this
.
_runInContext
)
this
.
_stream
=
primary
return
second
ary
})
// Node tee callback handlers run on event boundaries, so keep request ALS
// context stable for whichever branch is consumed later.
const
[
primary
,
secondary
]
=
teeNodeReadable
(
this
.
_stream
as
NodeReadable
,
this
.
_runInContext
)
this
.
_stream
=
prim
ary
return
secondary
}
else
{
throw
new
Error
(
'Cannot tee a Node.js stream in the edge runtime'
)
}
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
bca423c5
...
...
@@ -845,24 +845,15 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(
const
{
clientModules
}
=
getClientReferenceManifest
()
const
rscPayload
=
await
getPayload
(
requestStore
)
const
runInContext
=
<
T
,
>
(fn: () =
>
T): T =
>
workUnitAsyncStorage.run(requestStore, fn)
return
await
workUnitAsyncStorage
.
run
(
requestStore
,
scheduleInSequentialTasks
,
()
=>
{
stageController
.
advanceStage
(
RenderStage
.
Static
)
return
renderToFlightStream
(
ctx
.
componentMod
,
rscPayload
,
clientModules
,
{
...
options
,
environmentName
,
},
runInContext
)
return
renderToFlightStream
(
ctx
.
componentMod
,
rscPayload
,
clientModules
,
{
...
options
,
environmentName
,
})
},
()
=>
{
stageController
.
advanceStage
(
RenderStage
.
Dynamic
)
...
...
@@ -2847,6 +2838,8 @@ async function renderToStream(
setReactDebugChannel
(
browserChannel
,
htmlRequestId
,
requestId
)
}
// Node stream callbacks can run outside the originating ALS scope, so
// preserve the request store explicitly for downstream handlers.
const
runInContext
=
<
T
,
>
(fn: () =
>
T): T =
>
workUnitAsyncStorage.run(requestStore, fn)
reactServerResult = new ReactServerResult(
...
...
@@ -3266,6 +3259,8 @@ async function renderWithRestartOnCacheMissInDev(
initialStageController
.
advanceStage
(
RenderStage
.
Static
)
startTime
=
performance
.
now
()
+
performance
.
timeOrigin
// teeNodeReadable installs event handlers (`data`/`drain`/`end`/`close`)
// that may execute outside the current ALS frame.
const
runInContext
=
<
T
,
>
(fn: () =
>
T): T =
>
workUnitAsyncStorage.run(requestStore, fn)
...
...
@@ -3280,8 +3275,7 @@ async function renderWithRestartOnCacheMissInDev(
filterStackFrame
,
debugChannel
:
debugChannel
?.
serverSide
,
signal
:
initialReactController
.
signal
,
}
,
runInContext
}
)
// If we abort the render, we want to reject the stage-dependent promises as well.
// Note that we want to install this listener after the render is started
...
...
@@ -3448,6 +3442,8 @@ async function renderWithRestartOnCacheMissInDev(
finalStageController
.
advanceStage
(
RenderStage
.
Static
)
startTime
=
performance
.
now
()
+
performance
.
timeOrigin
// teeNodeReadable installs event handlers (`data`/`drain`/`end`/`close`)
// that may execute outside the current ALS frame.
const
runInContext
=
<
T
,
>
(fn: () =
>
T): T =
>
workUnitAsyncStorage.run(requestStore, fn)
...
...
@@ -3461,8 +3457,7 @@ async function renderWithRestartOnCacheMissInDev(
startTime
,
filterStackFrame
,
debugChannel
:
debugChannel
?.
serverSide
,
}
,
runInContext
}
)
if (
...
...
@@ -5889,6 +5884,8 @@ async function prerenderToStream(
errorType
)
// Keep prerender-legacy async storage stable across node stream event
// callbacks and pipeable renderer hooks.
const
runInLegacyContext
=
<
T
,
>
(fn: () =
>
T): T =
>
workUnitAsyncStorage.run(prerenderLegacyStore, fn)
...
...
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