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

ensure DIO development segment errors are cleared after correcting (#71811)

This clears segment config errors that are corrected in development mode
when using `dynamicIO`.
parent a549889b
......@@ -289,6 +289,7 @@ async function startWatcher(opts: SetupOpts) {
let enabledTypeScript = usingTypeScript
let previousClientRouterFilters: any
let previousConflictingPagePaths: Set<string> = new Set()
let previouslyHadSegmentError = false
wp.on('aggregated', async () => {
let middlewareMatchers: MiddlewareMatcher[] | undefined
......@@ -569,6 +570,10 @@ async function startWatcher(opts: SetupOpts) {
const errorMessage = `The following pages used segment configs which are not supported with "experimental.dynamicIO" and must be removed to build your application:\n${pagesWithIncompatibleSegmentConfigs.join('\n')}\n`
Log.error(errorMessage)
hotReloader.setHmrServerError(new Error(errorMessage))
previouslyHadSegmentError = true
} else if (previouslyHadSegmentError) {
hotReloader.clearHmrServerError()
previouslyHadSegmentError = false
}
}
......
import { nextTestSetup } from 'e2e-utils'
import {
assertHasRedbox,
assertNoRedbox,
getRedboxCallStack,
getRedboxDescription,
hasErrorToast,
retry,
waitForAndOpenRuntimeError,
getRedboxSource,
} from 'next-test-utils'
import { sandbox } from 'development-sandbox'
import { outdent } from 'outdent'
describe('Dynamic IO Dev Errors', () => {
const { next } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
})
......@@ -67,4 +71,56 @@ describe('Dynamic IO Dev Errors', () => {
expect(stack).toContain('Root [Server]')
expect(stack).toContain('<anonymous> (2:1)')
})
// `setHmrServerError` is not currently implemented in Turbopack
// we will need to enable this after it gets implemented.
if (!isTurbopack) {
it('should clear segment errors after correcting them', async () => {
const { cleanup, session, browser } = await sandbox(
next,
new Map([
[
'app/page.tsx',
outdent`
export const revalidate = 10
export default function Page() {
return (
<div>Hello World</div>
);
}
`,
],
])
)
await assertHasRedbox(browser)
const redbox = {
description: await getRedboxDescription(browser),
source: await getRedboxSource(browser),
}
expect(redbox.description).toMatchInlineSnapshot(`"Failed to compile"`)
expect(redbox.source).toMatchInlineSnapshot(`
"The following pages used segment configs which are not supported with "experimental.dynamicIO" and must be removed to build your application:
/: revalidate"
`)
await session.patch(
'app/page.tsx',
outdent`
export default function Page() {
return (
<div>Hello World</div>
);
}
`
)
await retry(async () => {
assertNoRedbox(browser)
})
await cleanup()
})
}
})
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