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
31f18201
Commit
31f18201
authored
Oct 16, 2025
by
Janka Uryga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor types for dev-only RequestStore properties
parent
66c194a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
26 deletions
+64
-26
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+23
-18
work-unit-async-storage.external.ts
...src/server/app-render/work-unit-async-storage.external.ts
+38
-6
use-cache-wrapper.ts
packages/next/src/server/use-cache/use-cache-wrapper.ts
+3
-2
No files found.
packages/next/src/server/app-render/app-render.tsx
View file @
31f18201
...
@@ -16,6 +16,7 @@ import {
...
@@ -16,6 +16,7 @@ import {
type
WorkStore
,
type
WorkStore
,
}
from
'../app-render/work-async-storage.external'
}
from
'../app-render/work-async-storage.external'
import
type
{
import
type
{
DevStoreModernPartial
,
PrerenderStoreModernRuntime
,
PrerenderStoreModernRuntime
,
RequestStore
,
RequestStore
,
}
from
'../app-render/work-unit-async-storage.external'
}
from
'../app-render/work-unit-async-storage.external'
...
@@ -2847,18 +2848,20 @@ async function renderWithRestartOnCacheMissInDev(
...
@@ -2847,18 +2848,20 @@ async function renderWithRestartOnCacheMissInDev(
initialHangingPromiseController
.
signal
initialHangingPromiseController
.
signal
)
)
requestStore
.
prerenderResumeDataCache
=
prerenderResumeDataCache
// `getRenderResumeDataCache` will fall back to using `prerenderResumeDataCache` as `renderResumeDataCache`,
// `getRenderResumeDataCache` will fall back to using `prerenderResumeDataCache` as `renderResumeDataCache`,
// so not having a resume data cache won't break any expectations in case we don't need to restart.
// so not having a resume data cache won't break any expectations in case we don't need to restart.
requestStore
.
renderResumeDataCache
=
null
requestStore
.
renderResumeDataCache
=
null
requestStore
.
stagedRendering
=
initialStageController
Object
.
assign
(
requestStore
,
{
requestStore
.
asyncApiPromises
=
createAsyncApiPromisesInDev
(
stagedRendering
:
initialStageController
,
initialStageController
,
asyncApiPromises
:
createAsyncApiPromisesInDev
(
requestStore
.
cookies
,
initialStageController
,
requestStore
.
mutableCookies
,
requestStore
.
cookies
,
requestStore
.
headers
requestStore
.
mutableCookies
,
)
requestStore
.
headers
requestStore
.
cacheSignal
=
cacheSignal
),
prerenderResumeDataCache
,
cacheSignal
,
}
satisfies
DevStoreModernPartial
)
let
debugChannel
=
setReactDebugChannel
&&
createDebugChannel
()
let
debugChannel
=
setReactDebugChannel
&&
createDebugChannel
()
...
@@ -2963,18 +2966,20 @@ async function renderWithRestartOnCacheMissInDev(
...
@@ -2963,18 +2966,20 @@ async function renderWithRestartOnCacheMissInDev(
// We've filled the caches, so now we can render as usual,
// We've filled the caches, so now we can render as usual,
// without any cache-filling mechanics.
// without any cache-filling mechanics.
requestStore
.
prerenderResumeDataCache
=
null
requestStore
.
renderResumeDataCache
=
createRenderResumeDataCache
(
requestStore
.
renderResumeDataCache
=
createRenderResumeDataCache
(
prerenderResumeDataCache
prerenderResumeDataCache
)
)
requestStore
.
stagedRendering
=
finalStageController
Object
.
assign
(
requestStore
,
{
requestStore
.
cacheSignal
=
null
stagedRendering
:
finalStageController
,
requestStore
.
asyncApiPromises
=
createAsyncApiPromisesInDev
(
asyncApiPromises
:
createAsyncApiPromisesInDev
(
finalStageController
,
finalStageController
,
requestStore
.
cookies
,
requestStore
.
cookies
,
requestStore
.
mutableCookies
,
requestStore
.
mutableCookies
,
requestStore
.
headers
requestStore
.
headers
)
),
prerenderResumeDataCache
:
null
,
cacheSignal
:
null
,
}
satisfies
DevStoreModernPartial
)
// The initial render already wrote to its debug channel.
// The initial render already wrote to its debug channel.
// We're not using it, so we need to create a new one.
// We're not using it, so we need to create a new one.
...
...
packages/next/src/server/app-render/work-unit-async-storage.external.ts
View file @
31f18201
...
@@ -29,7 +29,7 @@ export interface CommonWorkUnitStore {
...
@@ -29,7 +29,7 @@ export interface CommonWorkUnitStore {
readonly
implicitTags
:
ImplicitTags
readonly
implicitTags
:
ImplicitTags
}
}
export
interface
RequestStore
extends
CommonWorkUnitStore
{
interface
Base
RequestStore
extends
CommonWorkUnitStore
{
readonly
type
:
'request'
readonly
type
:
'request'
/**
/**
...
@@ -65,14 +65,46 @@ export interface RequestStore extends CommonWorkUnitStore {
...
@@ -65,14 +65,46 @@ export interface RequestStore extends CommonWorkUnitStore {
* The resume data cache for this request. This will be a immutable cache.
* The resume data cache for this request. This will be a immutable cache.
*/
*/
renderResumeDataCache
:
RenderResumeDataCache
|
null
renderResumeDataCache
:
RenderResumeDataCache
|
null
}
export
type
RequestStore
=
ProdRequestStore
|
DevRequestStore
export
type
ProdRequestStore
=
BaseRequestStore
&
AllMissing
<
DevStore
>
export
type
DevRequestStore
=
BaseRequestStore
&
DevStore
// DEV-only
// If `cacheComponents` is enabled, we add multiple extra properties on the store.
// We either want all of them to be present, or all of them to be undefined.
// Note that we don't want to remove the properties altogether, as in `{ a: A } | { a: A, b: B }`,
// because then typescript wouldn prevent us from doing `if (requestStore.someProp) { ... }` --
// we'd need to check `if ('someProp' in requestStore && requestStore.someProp) { ... }` instead,
// which is annoying to write everywhere.
type
DevStore
=
DevStoreLegacy
|
DevStoreModern
type
DevStoreLegacy
=
DevStoreCommon
&
AllMissing
<
DevStoreModernPartial
>
type
DevStoreModern
=
DevStoreCommon
&
DevStoreModernPartial
type
DevStoreCommon
=
{
usedDynamic
?:
boolean
usedDynamic
?:
boolean
devFallbackParams
?:
OpaqueFallbackRouteParams
|
null
devFallbackParams
?:
OpaqueFallbackRouteParams
|
null
stagedRendering
?:
StagedRenderingController
|
null
}
asyncApiPromises
?:
DevAsyncApiPromises
cacheSignal
?:
CacheSignal
|
null
export
type
DevStoreModernPartial
=
{
prerenderResumeDataCache
?:
PrerenderResumeDataCache
|
null
readonly
stagedRendering
:
StagedRenderingController
readonly
asyncApiPromises
:
DevAsyncApiPromises
}
&
(
|
{
// In the initial render, we track and fill caches
readonly
cacheSignal
:
CacheSignal
readonly
prerenderResumeDataCache
:
PrerenderResumeDataCache
}
|
{
// In the final (restarted) render, we do not track or fill caches
readonly
cacheSignal
:
null
readonly
prerenderResumeDataCache
:
null
}
)
type
AllMissing
<
TObj
extends
Record
<
string
,
any
>>
=
{
[
key
in
keyof
TObj
]?:
undefined
}
}
type
DevAsyncApiPromises
=
{
type
DevAsyncApiPromises
=
{
...
...
packages/next/src/server/use-cache/use-cache-wrapper.ts
View file @
31f18201
...
@@ -17,6 +17,7 @@ import { prerender } from 'react-server-dom-webpack/static'
...
@@ -17,6 +17,7 @@ import { prerender } from 'react-server-dom-webpack/static'
import
type
{
WorkStore
}
from
'../app-render/work-async-storage.external'
import
type
{
WorkStore
}
from
'../app-render/work-async-storage.external'
import
{
workAsyncStorage
}
from
'../app-render/work-async-storage.external'
import
{
workAsyncStorage
}
from
'../app-render/work-async-storage.external'
import
type
{
import
type
{
DevRequestStore
,
PrerenderStoreModernClient
,
PrerenderStoreModernClient
,
PrerenderStoreModernRuntime
,
PrerenderStoreModernRuntime
,
PrivateUseCacheStore
,
PrivateUseCacheStore
,
...
@@ -1848,7 +1849,7 @@ function isRecentlyRevalidatedTag(tag: string, workStore: WorkStore): boolean {
...
@@ -1848,7 +1849,7 @@ function isRecentlyRevalidatedTag(tag: string, workStore: WorkStore): boolean {
async
function
delayBeforeCacheReadStartInDev
(
async
function
delayBeforeCacheReadStartInDev
(
stage
:
NonStaticRenderStage
,
stage
:
NonStaticRenderStage
,
requestStore
:
RequestStore
requestStore
:
Dev
RequestStore
):
Promise
<
void
>
{
):
Promise
<
void
>
{
const
{
stagedRendering
}
=
requestStore
const
{
stagedRendering
}
=
requestStore
if
(
stagedRendering
&&
stagedRendering
.
currentStage
<
stage
)
{
if
(
stagedRendering
&&
stagedRendering
.
currentStage
<
stage
)
{
...
@@ -1859,7 +1860,7 @@ async function delayBeforeCacheReadStartInDev(
...
@@ -1859,7 +1860,7 @@ async function delayBeforeCacheReadStartInDev(
/** Note: Only call this after a `cacheSignal.beginRead()`. */
/** Note: Only call this after a `cacheSignal.beginRead()`. */
async
function
delayOrHangStartedCacheReadInDev
(
async
function
delayOrHangStartedCacheReadInDev
(
stage
:
NonStaticRenderStage
,
stage
:
NonStaticRenderStage
,
requestStore
:
RequestStore
,
requestStore
:
Dev
RequestStore
,
cacheSignal
:
CacheSignal
|
null
,
cacheSignal
:
CacheSignal
|
null
,
route
:
string
,
route
:
string
,
expression
:
string
expression
:
string
...
...
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