Unverified Commit de922af9 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

[dev-overlay]: generalize ISR status functions for pages/app (#76457)

This renames the functions associated with setting the ISR status (used for the static indicator in the error overlay) to be more generic, in preparation for it being used by pages router.
parent 6a5d6764
...@@ -340,7 +340,7 @@ function processMessage( ...@@ -340,7 +340,7 @@ function processMessage(
} }
switch (obj.action) { switch (obj.action) {
case HMR_ACTIONS_SENT_TO_BROWSER.APP_ISR_MANIFEST: { case HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST: {
if (process.env.__NEXT_DEV_INDICATOR) { if (process.env.__NEXT_DEV_INDICATOR) {
if (appIsrManifestRef) { if (appIsrManifestRef) {
appIsrManifestRef.current = obj.data appIsrManifestRef.current = obj.data
......
...@@ -90,7 +90,7 @@ export default (mode: 'webpack' | 'turbopack') => { ...@@ -90,7 +90,7 @@ export default (mode: 'webpack' | 'turbopack') => {
} }
case 'serverError': case 'serverError':
case 'devPagesManifestUpdate': case 'devPagesManifestUpdate':
case 'appIsrManifest': case 'isrManifest':
case 'building': case 'building':
case 'finishBuilding': { case 'finishBuilding': {
return return
......
...@@ -1211,7 +1211,7 @@ async function renderToHTMLOrFlightImpl( ...@@ -1211,7 +1211,7 @@ async function renderToHTMLOrFlightImpl(
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// reset isr status at start of request // reset isr status at start of request
const { pathname } = new URL(req.url || '/', 'http://n') const { pathname } = new URL(req.url || '/', 'http://n')
renderOpts.setAppIsrStatus?.(pathname, null) renderOpts.setIsrStatus?.(pathname, null)
} }
if ( if (
...@@ -1473,19 +1473,19 @@ async function renderToHTMLOrFlightImpl( ...@@ -1473,19 +1473,19 @@ async function renderToHTMLOrFlightImpl(
if ( if (
process.env.NODE_ENV === 'development' && process.env.NODE_ENV === 'development' &&
renderOpts.setAppIsrStatus && renderOpts.setIsrStatus &&
// The type check here ensures that `req` is correctly typed, and the // The type check here ensures that `req` is correctly typed, and the
// environment variable check provides dead code elimination. // environment variable check provides dead code elimination.
process.env.NEXT_RUNTIME !== 'edge' && process.env.NEXT_RUNTIME !== 'edge' &&
isNodeNextRequest(req) && isNodeNextRequest(req) &&
!isDevWarmupRequest !isDevWarmupRequest
) { ) {
const setAppIsrStatus = renderOpts.setAppIsrStatus const setIsrStatus = renderOpts.setIsrStatus
req.originalRequest.on('end', () => { req.originalRequest.on('end', () => {
if (!requestStore.usedDynamic && !workStore.forceDynamic) { if (!requestStore.usedDynamic && !workStore.forceDynamic) {
// only node can be ISR so we only need to update the status here // only node can be ISR so we only need to update the status here
const { pathname } = new URL(req.url || '/', 'http://n') const { pathname } = new URL(req.url || '/', 'http://n')
setAppIsrStatus(pathname, true) setIsrStatus(pathname, true)
} }
}) })
} }
......
...@@ -183,7 +183,7 @@ export interface RenderOptsPartial { ...@@ -183,7 +183,7 @@ export interface RenderOptsPartial {
cacheLifeProfiles?: { cacheLifeProfiles?: {
[profile: string]: import('../use-cache/cache-life').CacheLife [profile: string]: import('../use-cache/cache-life').CacheLife
} }
setAppIsrStatus?: (key: string, value: boolean | null) => void setIsrStatus?: (key: string, value: boolean | null) => void
isRevalidate?: boolean isRevalidate?: boolean
nextExport?: boolean nextExport?: boolean
nextConfigOutput?: 'standalone' | 'export' nextConfigOutput?: 'standalone' | 'export'
......
...@@ -2535,7 +2535,7 @@ export default abstract class Server< ...@@ -2535,7 +2535,7 @@ export default abstract class Server<
onClose: res.onClose.bind(res), onClose: res.onClose.bind(res),
onAfterTaskError: undefined, onAfterTaskError: undefined,
// only available in dev // only available in dev
setAppIsrStatus: (this as any).setAppIsrStatus, setIsrStatus: (this as any).setIsrStatus,
} }
if (isDebugStaticShell || isDebugDynamicAccesses) { if (isDebugStaticShell || isDebugDynamicAccesses) {
......
...@@ -23,7 +23,7 @@ export const enum HMR_ACTIONS_SENT_TO_BROWSER { ...@@ -23,7 +23,7 @@ export const enum HMR_ACTIONS_SENT_TO_BROWSER {
TURBOPACK_MESSAGE = 'turbopack-message', TURBOPACK_MESSAGE = 'turbopack-message',
SERVER_ERROR = 'serverError', SERVER_ERROR = 'serverError',
TURBOPACK_CONNECTED = 'turbopack-connected', TURBOPACK_CONNECTED = 'turbopack-connected',
APP_ISR_MANIFEST = 'appIsrManifest', ISR_MANIFEST = 'isrManifest',
} }
interface ServerErrorAction { interface ServerErrorAction {
...@@ -112,7 +112,7 @@ export interface TurbopackConnectedAction { ...@@ -112,7 +112,7 @@ export interface TurbopackConnectedAction {
} }
export interface AppIsrManifestAction { export interface AppIsrManifestAction {
action: HMR_ACTIONS_SENT_TO_BROWSER.APP_ISR_MANIFEST action: HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST
data: Record<string, boolean> data: Record<string, boolean>
} }
......
...@@ -93,14 +93,14 @@ export class DevBundlerService { ...@@ -93,14 +93,14 @@ export class DevBundlerService {
return serializableManifest return serializableManifest
} }
public setAppIsrStatus(key: string, value: boolean | null) { public setIsrStatus(key: string, value: boolean | null) {
if (value === null) { if (value === null) {
this.appIsrManifestInner.remove(key) this.appIsrManifestInner.remove(key)
} else { } else {
this.appIsrManifestInner.set(key, value) this.appIsrManifestInner.set(key, value)
} }
this.bundler?.hotReloader?.send({ this.bundler?.hotReloader?.send({
action: HMR_ACTIONS_SENT_TO_BROWSER.APP_ISR_MANIFEST, action: HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST,
data: this.appIsrManifest, data: this.appIsrManifest,
}) })
} }
......
...@@ -625,8 +625,7 @@ export async function initialize(opts: { ...@@ -625,8 +625,7 @@ export async function initialize(opts: {
server: opts.server, server: opts.server,
serverFields: { serverFields: {
...(developmentBundler?.serverFields || {}), ...(developmentBundler?.serverFields || {}),
setAppIsrStatus: setIsrStatus: devBundlerService?.setIsrStatus.bind(devBundlerService),
devBundlerService?.setAppIsrStatus.bind(devBundlerService),
} satisfies ServerFields, } satisfies ServerFields,
experimentalTestProxy: !!config.experimental.testProxy, experimentalTestProxy: !!config.experimental.testProxy,
experimentalHttpsServer: !!opts.experimentalHttpsServer, experimentalHttpsServer: !!opts.experimentalHttpsServer,
...@@ -710,7 +709,7 @@ export async function initialize(opts: { ...@@ -710,7 +709,7 @@ export async function initialize(opts: {
(client) => { (client) => {
client.send( client.send(
JSON.stringify({ JSON.stringify({
action: HMR_ACTIONS_SENT_TO_BROWSER.APP_ISR_MANIFEST, action: HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST,
data: devBundlerService?.appIsrManifest || {}, data: devBundlerService?.appIsrManifest || {},
} satisfies AppIsrManifestAction) } satisfies AppIsrManifestAction)
) )
......
...@@ -109,7 +109,7 @@ export type ServerFields = { ...@@ -109,7 +109,7 @@ export type ServerFields = {
interceptionRoutes?: ReturnType< interceptionRoutes?: ReturnType<
typeof import('./filesystem').buildCustomRoute typeof import('./filesystem').buildCustomRoute
>[] >[]
setAppIsrStatus?: (key: string, value: boolean) => void setIsrStatus?: (key: string, value: boolean) => void
resetFetch?: () => void resetFetch?: () => 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