Skip to content

Commit ce5206f

Browse files
authored
[dynamicIO] Fix dev warmup (#77829)
When `dynamicIO` is enabled, we're triggering a warmup request in dev mode. This ensures that replayed logs are associated with the correct environment (`Prerender` vs. `Server`), by seeding the caches before the actual render. This PR fixes two issues with the dev warmup: - Ensures that cache keys are identical between the warmup, the subsequent dynamic render, and the dynamic validation, by providing the HMR refresh hash (part of the cache key) for all dev render phases. - Ensures that stale cache entries are discarded during the warmup, by providing the implicit tags also during the warmup (and the dynamic validation).
1 parent f1312ef commit ce5206f

File tree

9 files changed

+150
-66
lines changed

9 files changed

+150
-66
lines changed

packages/next/src/client/components/app-router-headers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const NEXT_ROUTER_PREFETCH_HEADER = 'Next-Router-Prefetch' as const
1212
export const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER =
1313
'Next-Router-Segment-Prefetch' as const
1414
export const NEXT_HMR_REFRESH_HEADER = 'Next-HMR-Refresh' as const
15+
export const NEXT_HMR_REFRESH_HASH_COOKIE = '__next_hmr_refresh_hash__' as const
1516
export const NEXT_URL = 'Next-Url' as const
1617
export const RSC_CONTENT_TYPE_HEADER = 'text/x-component' as const
1718

packages/next/src/client/components/react-dev-overlay/app/hot-reloader-client.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type { GlobalErrorComponent } from '../../error-boundary'
4646
import type { DevIndicatorServerState } from '../../../../server/dev/dev-indicator-server-state'
4747
import reportHmrLatency from '../utils/report-hmr-latency'
4848
import { TurbopackHmr } from '../utils/turbopack-hot-reloader-common'
49+
import { NEXT_HMR_REFRESH_HASH_COOKIE } from '../../app-router-headers'
4950

5051
export interface Dispatcher {
5152
onBuildOk(): void
@@ -412,7 +413,7 @@ function processMessage(
412413

413414
// Store the latest hash in a session cookie so that it's sent back to the
414415
// server with any subsequent requests.
415-
document.cookie = `__next_hmr_refresh_hash__=${obj.hash}`
416+
document.cookie = `${NEXT_HMR_REFRESH_HASH_COOKIE}=${obj.hash}`
416417

417418
if (RuntimeErrorHandler.hadRuntimeError) {
418419
if (reloading) return

0 commit comments

Comments
 (0)