Skip to content

Commit

Permalink
Fix static indicator with dynamicIO (vercel#72631)
Browse files Browse the repository at this point in the history
This ensures we don't incorrectly update the static indicator status
during the dev warmup render which was causing it to show unexpectedly
with dynamicIO enabled.
  • Loading branch information
ijjk authored Nov 12, 2024
1 parent 1b1cb3e commit dd8c465
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,8 @@ async function renderToHTMLOrFlightImpl(
// The type check here ensures that `req` is correctly typed, and the
// environment variable check provides dead code elimination.
process.env.NEXT_RUNTIME !== 'edge' &&
isNodeNextRequest(req)
isNodeNextRequest(req) &&
!isDevWarmupRequest
) {
const setAppIsrStatus = renderOpts.setAppIsrStatus
req.originalRequest.on('end', () => {
Expand Down
39 changes: 39 additions & 0 deletions test/e2e/app-dir/dynamic-io/dynamic-io.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable jest/no-standalone-expect */
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { BrowserInterface } from 'next-webdriver'

const WITH_PPR = !!process.env.__NEXT_EXPERIMENTAL_PPR

Expand All @@ -15,6 +17,43 @@ describe('dynamic-io', () => {

const itSkipTurbopack = isTurbopack ? it.skip : it

if (isNextDev && !WITH_PPR) {
async function hasStaticIndicator(browser: BrowserInterface) {
const staticIndicatorPresent = await browser.eval(() =>
Boolean(
document
.querySelector('nextjs-portal')
.shadowRoot.querySelector('.nextjs-static-indicator-toast-wrapper')
)
)
return staticIndicatorPresent
}

it('should not have static indicator on dynamic route', async () => {
const browser = await next.browser('/cases/dynamic_api_cookies')

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')

await retry(async () => {
expect(await browser.eval('!!window.next.router ? "yes": "no"')).toBe(
'yes'
)
})

expect(await hasStaticIndicator(browser)).toBe(true)
})
}

it('should not have route specific errors', async () => {
expect(next.cliOutput).not.toMatch('Error: Route "/')
expect(next.cliOutput).not.toMatch('Error occurred prerendering page')
Expand Down

0 comments on commit dd8c465

Please sign in to comment.