Commit 31b2f51a authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Don't mark page as nextExport if it's SPR (#9113)

* Don't mark page as nextExport if it's SPR

* Add test for fetching prerender data after mount
parent 8b48508c
...@@ -313,6 +313,7 @@ export async function renderToHTML( ...@@ -313,6 +313,7 @@ export async function renderToHTML(
} }
} }
if (isAutoExport) renderOpts.autoExport = true if (isAutoExport) renderOpts.autoExport = true
if (isSpr) renderOpts.nextExport = false
await Loadable.preloadAll() // Make sure all dynamic imports are loaded await Loadable.preloadAll() // Make sure all dynamic imports are loaded
......
...@@ -18,6 +18,10 @@ export async function unstable_getStaticProps ({ params }) { ...@@ -18,6 +18,10 @@ export async function unstable_getStaticProps ({ params }) {
}) })
} }
if (params.post === 'post-100') {
throw new Error('such broken..')
}
return { return {
props: { props: {
post: params.post, post: params.post,
......
...@@ -327,6 +327,14 @@ const runTests = (dev = false) => { ...@@ -327,6 +327,14 @@ const runTests = (dev = false) => {
expect(newJson).toMatch(/post-2/) expect(newJson).toMatch(/post-2/)
expect(newJson).toMatch(/comment-3/) expect(newJson).toMatch(/comment-3/)
}) })
it('should not fetch prerender data on mount', async () => {
const browser = await webdriver(appPort, '/blog/post-100')
await browser.eval('window.thisShouldStay = true')
await waitFor(2 * 1000)
const val = await browser.eval('window.thisShouldStay')
expect(val).toBe(true)
})
} }
} }
......
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