mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
The issue was that DOM bots with PPR-enabled routes were being forced to use BLOCKING_STATIC_RENDER mode, which prevented them from using the fallback cache lookup mechanism. This caused them to generate new content with isRevalidating: true, which blocks postponed data and triggers the Math.random() static generation bailout error. For HTML bots, they keep using BLOCKING_STATIC_RENDER because SSG was turned off for them and won't see the SSG bailout error. For DOM bots, they should behave like a normal user. Fixes NAR-273
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('cache-components PPR bot static generation bypass', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should bypass static generation for DOM bot requests to avoid SSG_BAILOUT', async () => {
|
|
const res = await next.fetch('/foo', {
|
|
headers: {
|
|
'user-agent': 'Googlebot',
|
|
},
|
|
})
|
|
// With cache components + PPR enabled, DOM bots should behave like regular users
|
|
// and use the fallback cache mechanism. This allows them to handle dynamic content
|
|
// like Math.random() without triggering SSG_BAILOUT errors.
|
|
expect(res.status).toBe(200)
|
|
|
|
// Verify that the response contains the page content
|
|
const html = await res.text()
|
|
|
|
// Check that the page rendered successfully
|
|
// With PPR, content is streamed via script tags
|
|
expect(html).toContain('\\"children\\":\\"foo\\"')
|
|
|
|
// Verify Math.random() was executed (check for a decimal number in the streamed content)
|
|
expect(html).toMatch(/\\"children\\":0\.\d+/)
|
|
|
|
// With PPR, content is streamed, but the important thing is that
|
|
// the page rendered without a 500 error
|
|
})
|
|
})
|