Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static indicator with dynamicIO #72631

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading