-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure we don't poll page in development when notFound: true is retur…
…ned (#34352) Fixes: #34342 Visiting the following page will call gSSP indefinitely in a loop and logs errors from `on-demand-entries-client`: ```js const Home = () => null export default Home export function getServerSideProps() { console.log("gssp called") return { notFound: true } } ``` We should not keep fetching the page if it returns 404 as it can introduce unnecessary data requests. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
- Loading branch information
1 parent
7e93a89
commit 9639fe7
Showing
6 changed files
with
53 additions
and
1 deletion.
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,34 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { waitFor } from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
|
||
describe('getServerSideProps returns notFound: true', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
'pages/index.js': ` | ||
const Home = () => null | ||
export default Home | ||
export function getServerSideProps() { | ||
console.log("gssp called") | ||
return { notFound: true } | ||
} | ||
`, | ||
}, | ||
dependencies: {}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should not poll indefinitely', async () => { | ||
const browser = await webdriver(next.appPort, '/') | ||
await waitFor(3000) | ||
await browser.close() | ||
const logOccurrences = next.cliOutput.split('gssp called').length - 1 | ||
expect(logOccurrences).toBe(1) | ||
}) | ||
}) |