Unverified Commit 0bc2346e authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix static indicator for pure IO case (#72639)

Follow-up to https://github.com/vercel/next.js/pull/72631 this ensures
we properly update the `requestStore` when we detect pure IO case and no
dynamic methods are used like `cookies()` or `headers()` e.g. just a
fetch with no caching opts enabled.

---------
Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
parent 3c3710be
......@@ -562,7 +562,8 @@ async function generateDynamicFlightRenderResult(
ctx,
false,
ctx.clientReferenceManifest,
ctx.workStore.route
ctx.workStore.route,
requestStore
)
}
......@@ -1654,7 +1655,8 @@ async function renderToStream(
ctx,
res.statusCode === 404,
clientReferenceManifest,
workStore.route
workStore.route,
requestStore
)
reactServerResult = new ReactServerResult(reactServerStream)
......@@ -1980,7 +1982,8 @@ async function spawnDynamicValidationInDev(
ctx: AppRenderContext,
isNotFound: boolean,
clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>,
route: string
route: string,
requestStore: RequestStore
): Promise<void> {
const { componentMod: ComponentMod } = ctx
......@@ -2235,6 +2238,8 @@ async function spawnDynamicValidationInDev(
isPrerenderInterruptedError(err) ||
finalClientController.signal.aborted
) {
requestStore.usedDynamic = true
const componentStack: string | undefined = (errorInfo as any)
.componentStack
if (typeof componentStack === 'string') {
......
......@@ -29,7 +29,7 @@ describe('dynamic-io', () => {
return staticIndicatorPresent
}
it('should not have static indicator on dynamic route', async () => {
it('should not have static indicator on dynamic method route', async () => {
const browser = await next.browser('/cases/dynamic_api_cookies')
await retry(async () => {
......@@ -41,6 +41,18 @@ describe('dynamic-io', () => {
expect(await hasStaticIndicator(browser)).toBe(false)
})
it('should not have static indicator on dynamic IO route', async () => {
const browser = await next.browser('/cases/fetch_mixed')
await retry(async () => {
expect(await browser.eval('!!window.next.router ? "yes": "no"')).toBe(
'yes'
)
})
expect(await hasStaticIndicator(browser)).toBe(false)
})
it('should have static indicator on static route', async () => {
const browser = await next.browser('/cases/static')
......
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