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: prevent infinite dev refresh on nested parallel routes #52362

Merged
merged 2 commits into from
Jul 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/next/src/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export function getEntryKey(
pageBundleType: 'app' | 'pages' | 'root',
page: string
) {
// TODO: handle the /@children slot better
// this is a quick hack to handle when children is provided as @children/page instead of /page
return `${compilerType}@${pageBundleType}@${page.replace(/\/@children/g, '')}`
// TODO: handle the /children slot better
// this is a quick hack to handle when children is provided as children/page instead of /page
return `${compilerType}@${pageBundleType}@${page.replace(/\/children/g, '')}`
}

function getPageBundleType(pageBundlePath: string) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function ParallelPage() {
return (
<>
<p>Hello from nested parallel page!</p>
<div id="timestamp">{Date.now()}</div>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function Layout({ parallelB }: { parallelB: React.ReactNode }) {
return (
<main>
<h3>{`(parallelB)`}</h3>
<div>{parallelB}</div>
</main>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function Parallel({ children }) {
return (
<div>
parallel/layout:
<div className="parallel" title="children">
{children}
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,21 @@ createNextDescribe(
return newTimestamp !== timestamp ? 'failure' : 'success'
}, 'success')
})

it('should support nested parallel routes', async () => {
const browser = await next.browser('parallel-nested/home/nested')
const timestamp = await browser.elementByCss('#timestamp').text()

await new Promise((resolve) => {
setTimeout(resolve, 3000)
})

await check(async () => {
// an invalid response triggers a fast refresh, so if the timestamp doesn't update, this behaved correctly
const newTimestamp = await browser.elementByCss('#timestamp').text()
return newTimestamp !== timestamp ? 'failure' : 'success'
}, 'success')
})
}
})

Expand Down