-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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 routing bug when bfcache is hit following an mpa navigation #54081
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d49ecff
fix routing bug when bfcache is hit after an mpa navigation
ztanner 6ee7015
force headed mode for test; use window.history.state instead of initi…
ztanner bc2b4e6
Merge branch 'canary' into fix/link-mpa-navigation
ztanner 4048511
Merge branch 'canary' into fix/link-mpa-navigation
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html> | ||
<head></head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client' | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
const [counter, setCounter] = React.useState(0) | ||
return ( | ||
<div> | ||
<button onClick={() => setCounter((c) => c + 1)}> | ||
Trigger Re-Render | ||
</button> | ||
<div id="counter">{counter}</div> | ||
<Link href="https://example.vercel.sh">External Page</Link> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Server } from 'http' | ||
import { | ||
findPort, | ||
nextBuild, | ||
startStaticServer, | ||
stopApp, | ||
} from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
import { join } from 'path' | ||
|
||
describe('export-routing', () => { | ||
let port: number | ||
let app: Server | ||
|
||
beforeAll(async () => { | ||
const appDir = __dirname | ||
const exportDir = join(appDir, 'out') | ||
|
||
await nextBuild(appDir, undefined, { cwd: appDir }) | ||
port = await findPort() | ||
app = await startStaticServer(exportDir, undefined, port) | ||
}) | ||
|
||
afterAll(() => { | ||
stopApp(app) | ||
}) | ||
|
||
it('should not suspend indefinitely when page is restored from bfcache after an mpa navigation', async () => { | ||
// bfcache is not currently supported by CDP, so we need to run this particular test in headed mode | ||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1317959 | ||
if (!process.env.CI && process.env.HEADLESS) { | ||
console.warn('This test can only run in headed mode. Skipping...') | ||
return | ||
} | ||
|
||
const browser = await webdriver(port, '/index.html', { headless: false }) | ||
|
||
await browser.elementByCss('a[href="https://example.vercel.sh"]').click() | ||
await browser.waitForCondition( | ||
'window.location.origin === "https://example.vercel.sh"' | ||
) | ||
|
||
// this will never resolve in the failure case, as the page will be suspended indefinitely | ||
await browser.back() | ||
|
||
expect(await browser.elementByCss('#counter').text()).toBe('0') | ||
|
||
// click the button | ||
await browser.elementByCss('button').click() | ||
|
||
// counter should be 1 | ||
expect(await browser.elementByCss('#counter').text()).toBe('1') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: 'export', | ||
} | ||
|
||
module.exports = nextConfig |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a very confusing line... but this is saying "don't disable bfcache by default", since Playwright automatically disables it (ref)
Our tests pass seem to pass with it enabled, but I'm not opposed to having this be an option insteadRealizing this won’t really make a difference in CI since we’re running them headless, added an option to force non-headless in 6ee7015