Remove unused `requestId` parameter from `setCacheStatus`

Setting the cache status for a page in dev mode is a sequential
operation that only requires the HTML request ID to identify WebSocket
clients across different browser tabs/windows. This is different from
connecting the React debug channel (after which the cache status
handling was modeled), which requires both the HTML request ID as well
as the request ID to correctly associate debug chunks within a client
with the matching request, which might be for the HTML document, a
client-side navigation, or a server function call.
parent 7fef3a0c
...@@ -792,7 +792,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev( ...@@ -792,7 +792,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
// Before we kick off the render, we set the cache status back to it's initial state // Before we kick off the render, we set the cache status back to it's initial state
// in case a previous render bypassed the cache. // in case a previous render bypassed the cache.
if (setCacheStatus) { if (setCacheStatus) {
setCacheStatus('ready', htmlRequestId, requestId) setCacheStatus('ready', htmlRequestId)
} }
const result = await renderWithRestartOnCacheMissInDev( const result = await renderWithRestartOnCacheMissInDev(
...@@ -812,7 +812,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev( ...@@ -812,7 +812,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
// Set cache status to bypass when specifically bypassing caches in dev // Set cache status to bypass when specifically bypassing caches in dev
if (setCacheStatus) { if (setCacheStatus) {
setCacheStatus('bypass', htmlRequestId, requestId) setCacheStatus('bypass', htmlRequestId)
} }
debugChannel = setReactDebugChannel && createDebugChannel() debugChannel = setReactDebugChannel && createDebugChannel()
...@@ -2613,7 +2613,7 @@ async function renderToStream( ...@@ -2613,7 +2613,7 @@ async function renderToStream(
// This lets the client know not to cache anything based on this render. // This lets the client know not to cache anything based on this render.
if (renderOpts.setCacheStatus) { if (renderOpts.setCacheStatus) {
// we know this is available when cacheComponents is enabled, but typeguard to be safe // we know this is available when cacheComponents is enabled, but typeguard to be safe
renderOpts.setCacheStatus('bypass', htmlRequestId, requestId) renderOpts.setCacheStatus('bypass', htmlRequestId)
} }
payload._bypassCachesInDev = createElement(WarnForBypassCachesInDev, { payload._bypassCachesInDev = createElement(WarnForBypassCachesInDev, {
route: workStore.route, route: workStore.route,
...@@ -3060,7 +3060,6 @@ async function renderWithRestartOnCacheMissInDev( ...@@ -3060,7 +3060,6 @@ async function renderWithRestartOnCacheMissInDev(
const { const {
htmlRequestId, htmlRequestId,
renderOpts, renderOpts,
requestId,
componentMod: { componentMod: {
routeModule: { routeModule: {
userland: { loaderTree }, userland: { loaderTree },
...@@ -3203,7 +3202,7 @@ async function renderWithRestartOnCacheMissInDev( ...@@ -3203,7 +3202,7 @@ async function renderWithRestartOnCacheMissInDev(
} }
if (process.env.NODE_ENV === 'development' && setCacheStatus) { if (process.env.NODE_ENV === 'development' && setCacheStatus) {
setCacheStatus('filling', htmlRequestId, requestId) setCacheStatus('filling', htmlRequestId)
} }
// Cache miss. We will use the initial render to fill caches, and discard its result. // Cache miss. We will use the initial render to fill caches, and discard its result.
...@@ -3276,7 +3275,7 @@ async function renderWithRestartOnCacheMissInDev( ...@@ -3276,7 +3275,7 @@ async function renderWithRestartOnCacheMissInDev(
) )
if (process.env.NODE_ENV === 'development' && setCacheStatus) { if (process.env.NODE_ENV === 'development' && setCacheStatus) {
setCacheStatus('filled', htmlRequestId, requestId) setCacheStatus('filled', htmlRequestId)
} }
return { return {
......
...@@ -109,11 +109,7 @@ export interface RenderOptsPartial { ...@@ -109,11 +109,7 @@ export interface RenderOptsPartial {
} }
isOnDemandRevalidate?: boolean isOnDemandRevalidate?: boolean
isPossibleServerAction?: boolean isPossibleServerAction?: boolean
setCacheStatus?: ( setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
) => void
setIsrStatus?: (key: string, value: boolean | undefined) => void setIsrStatus?: (key: string, value: boolean | undefined) => void
setReactDebugChannel?: ( setReactDebugChannel?: (
debugChannel: { readable: ReadableStream<Uint8Array> }, debugChannel: { readable: ReadableStream<Uint8Array> },
......
...@@ -1132,11 +1132,7 @@ export async function createHotReloaderTurbopack( ...@@ -1132,11 +1132,7 @@ export async function createHotReloaderTurbopack(
} }
}, },
setCacheStatus( setCacheStatus(status: ServerCacheStatus, htmlRequestId: string): void {
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
): void {
// Legacy clients don't have Cache Components. // Legacy clients don't have Cache Components.
const client = clientsByRequestId.get(htmlRequestId) const client = clientsByRequestId.get(htmlRequestId)
if (client !== undefined) { if (client !== undefined) {
...@@ -1147,7 +1143,7 @@ export async function createHotReloaderTurbopack( ...@@ -1147,7 +1143,7 @@ export async function createHotReloaderTurbopack(
} else { } else {
// If the client is not connected, store the status so that we can send it // If the client is not connected, store the status so that we can send it
// when the client connects. // when the client connects.
cacheStatusesByRequestId.set(requestId, status) cacheStatusesByRequestId.set(htmlRequestId, status)
} }
}, },
......
...@@ -229,11 +229,7 @@ export interface NextJsHotReloaderInterface { ...@@ -229,11 +229,7 @@ export interface NextJsHotReloaderInterface {
* and App Router clients that don't have Cache Components enabled. * and App Router clients that don't have Cache Components enabled.
*/ */
sendToLegacyClients(action: HmrMessageSentToBrowser): void sendToLegacyClients(action: HmrMessageSentToBrowser): void
setCacheStatus( setCacheStatus(status: ServerCacheStatus, htmlRequestId: string): void
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
): void
setReactDebugChannel( setReactDebugChannel(
debugChannel: ReactDebugChannelForBrowser, debugChannel: ReactDebugChannelForBrowser,
htmlRequestId: string, htmlRequestId: string,
......
...@@ -1748,8 +1748,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface { ...@@ -1748,8 +1748,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface {
public setCacheStatus( public setCacheStatus(
status: ServerCacheStatus, status: ServerCacheStatus,
htmlRequestId: string, htmlRequestId: string
requestId: string
): void { ): void {
const client = this.webpackHotMiddleware?.getClient(htmlRequestId) const client = this.webpackHotMiddleware?.getClient(htmlRequestId)
if (client !== undefined) { if (client !== undefined) {
...@@ -1760,7 +1759,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface { ...@@ -1760,7 +1759,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface {
} else { } else {
// If the client is not connected, store the status so that we can send it // If the client is not connected, store the status so that we can send it
// when the client connects. // when the client connects.
this.cacheStatusesByRequestId.set(requestId, status) this.cacheStatusesByRequestId.set(htmlRequestId, status)
} }
} }
......
...@@ -98,10 +98,9 @@ export class DevBundlerService { ...@@ -98,10 +98,9 @@ export class DevBundlerService {
public setCacheStatus( public setCacheStatus(
status: ServerCacheStatus, status: ServerCacheStatus,
htmlRequestId: string, htmlRequestId: string
requestId: string
): void { ): void {
this.bundler.hotReloader.setCacheStatus(status, htmlRequestId, requestId) this.bundler.hotReloader.setCacheStatus(status, htmlRequestId)
} }
public setIsrStatus(key: string, value: boolean | undefined) { public setIsrStatus(key: string, value: boolean | undefined) {
......
...@@ -44,11 +44,7 @@ export type RouterServerContext = Record< ...@@ -44,11 +44,7 @@ export type RouterServerContext = Record<
htmlRequestId: string, htmlRequestId: string,
requestId: string requestId: string
) => void ) => void
setCacheStatus?: ( setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
) => void
} }
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment