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( ...@@ -562,7 +562,8 @@ async function generateDynamicFlightRenderResult(
ctx, ctx,
false, false,
ctx.clientReferenceManifest, ctx.clientReferenceManifest,
ctx.workStore.route ctx.workStore.route,
requestStore
) )
} }
...@@ -1654,7 +1655,8 @@ async function renderToStream( ...@@ -1654,7 +1655,8 @@ async function renderToStream(
ctx, ctx,
res.statusCode === 404, res.statusCode === 404,
clientReferenceManifest, clientReferenceManifest,
workStore.route workStore.route,
requestStore
) )
reactServerResult = new ReactServerResult(reactServerStream) reactServerResult = new ReactServerResult(reactServerStream)
...@@ -1980,7 +1982,8 @@ async function spawnDynamicValidationInDev( ...@@ -1980,7 +1982,8 @@ async function spawnDynamicValidationInDev(
ctx: AppRenderContext, ctx: AppRenderContext,
isNotFound: boolean, isNotFound: boolean,
clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>, clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>,
route: string route: string,
requestStore: RequestStore
): Promise<void> { ): Promise<void> {
const { componentMod: ComponentMod } = ctx const { componentMod: ComponentMod } = ctx
...@@ -2235,6 +2238,8 @@ async function spawnDynamicValidationInDev( ...@@ -2235,6 +2238,8 @@ async function spawnDynamicValidationInDev(
isPrerenderInterruptedError(err) || isPrerenderInterruptedError(err) ||
finalClientController.signal.aborted finalClientController.signal.aborted
) { ) {
requestStore.usedDynamic = true
const componentStack: string | undefined = (errorInfo as any) const componentStack: string | undefined = (errorInfo as any)
.componentStack .componentStack
if (typeof componentStack === 'string') { if (typeof componentStack === 'string') {
......
...@@ -29,7 +29,7 @@ describe('dynamic-io', () => { ...@@ -29,7 +29,7 @@ describe('dynamic-io', () => {
return staticIndicatorPresent 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') const browser = await next.browser('/cases/dynamic_api_cookies')
await retry(async () => { await retry(async () => {
...@@ -41,6 +41,18 @@ describe('dynamic-io', () => { ...@@ -41,6 +41,18 @@ describe('dynamic-io', () => {
expect(await hasStaticIndicator(browser)).toBe(false) 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 () => { it('should have static indicator on static route', async () => {
const browser = await next.browser('/cases/static') 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