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(
// 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.
if (setCacheStatus) {
setCacheStatus('ready', htmlRequestId, requestId)
setCacheStatus('ready', htmlRequestId)
}
const result = await renderWithRestartOnCacheMissInDev(
......@@ -812,7 +812,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
// Set cache status to bypass when specifically bypassing caches in dev
if (setCacheStatus) {
setCacheStatus('bypass', htmlRequestId, requestId)
setCacheStatus('bypass', htmlRequestId)
}
debugChannel = setReactDebugChannel && createDebugChannel()
......@@ -2613,7 +2613,7 @@ async function renderToStream(
// This lets the client know not to cache anything based on this render.
if (renderOpts.setCacheStatus) {
// 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, {
route: workStore.route,
......@@ -3060,7 +3060,6 @@ async function renderWithRestartOnCacheMissInDev(
const {
htmlRequestId,
renderOpts,
requestId,
componentMod: {
routeModule: {
userland: { loaderTree },
......@@ -3203,7 +3202,7 @@ async function renderWithRestartOnCacheMissInDev(
}
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.
......@@ -3276,7 +3275,7 @@ async function renderWithRestartOnCacheMissInDev(
)
if (process.env.NODE_ENV === 'development' && setCacheStatus) {
setCacheStatus('filled', htmlRequestId, requestId)
setCacheStatus('filled', htmlRequestId)
}
return {
......
......@@ -109,11 +109,7 @@ export interface RenderOptsPartial {
}
isOnDemandRevalidate?: boolean
isPossibleServerAction?: boolean
setCacheStatus?: (
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
) => void
setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: string) => void
setIsrStatus?: (key: string, value: boolean | undefined) => void
setReactDebugChannel?: (
debugChannel: { readable: ReadableStream<Uint8Array> },
......
......@@ -1132,11 +1132,7 @@ export async function createHotReloaderTurbopack(
}
},
setCacheStatus(
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
): void {
setCacheStatus(status: ServerCacheStatus, htmlRequestId: string): void {
// Legacy clients don't have Cache Components.
const client = clientsByRequestId.get(htmlRequestId)
if (client !== undefined) {
......@@ -1147,7 +1143,7 @@ export async function createHotReloaderTurbopack(
} else {
// If the client is not connected, store the status so that we can send it
// when the client connects.
cacheStatusesByRequestId.set(requestId, status)
cacheStatusesByRequestId.set(htmlRequestId, status)
}
},
......
......@@ -229,11 +229,7 @@ export interface NextJsHotReloaderInterface {
* and App Router clients that don't have Cache Components enabled.
*/
sendToLegacyClients(action: HmrMessageSentToBrowser): void
setCacheStatus(
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
): void
setCacheStatus(status: ServerCacheStatus, htmlRequestId: string): void
setReactDebugChannel(
debugChannel: ReactDebugChannelForBrowser,
htmlRequestId: string,
......
......@@ -1748,8 +1748,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface {
public setCacheStatus(
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
htmlRequestId: string
): void {
const client = this.webpackHotMiddleware?.getClient(htmlRequestId)
if (client !== undefined) {
......@@ -1760,7 +1759,7 @@ export default class HotReloaderWebpack implements NextJsHotReloaderInterface {
} else {
// If the client is not connected, store the status so that we can send it
// when the client connects.
this.cacheStatusesByRequestId.set(requestId, status)
this.cacheStatusesByRequestId.set(htmlRequestId, status)
}
}
......
......@@ -98,10 +98,9 @@ export class DevBundlerService {
public setCacheStatus(
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
htmlRequestId: string
): void {
this.bundler.hotReloader.setCacheStatus(status, htmlRequestId, requestId)
this.bundler.hotReloader.setCacheStatus(status, htmlRequestId)
}
public setIsrStatus(key: string, value: boolean | undefined) {
......
......@@ -44,11 +44,7 @@ export type RouterServerContext = Record<
htmlRequestId: string,
requestId: string
) => void
setCacheStatus?: (
status: ServerCacheStatus,
htmlRequestId: string,
requestId: string
) => void
setCacheStatus?: (status: ServerCacheStatus, htmlRequestId: 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