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

ensure DIO development segment errors are cleared after correcting #71811

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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
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,
})

Expand Down Expand Up @@ -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()
})
}
})
Loading