Commit graph

12 commits

Author SHA1 Message Date
Wyatt Johnson
4c2120d701
searchParameters test for PPR (#59678)
This adds a test that verifies that the search parameters sent to the
server while Partial Prerendering is enabled is actually sent and can be
used by the page.

Closes NEXT-1890
2024-01-03 09:30:22 +01:00
Wyatt Johnson
2da04af2e8
Partial Pre Rendering Headers (#59447)
This fixes some of headers (and adds associated tests) for pages when
PPR is enabled. Namely, the `Cache-Control` headers are now returning
correctly, reflecting the non-cachability of some requests:

- Requests that postpone (dynamic data is streamed after the initial
static shell is streamed)
- Requests for the Dynamic RSC payload

Additionally, the `X-NextJS-Cache` header has been updated for better
support for PPR:

- Requests that postpone no longer return this header as it doesn't
reflect the cache state of the request (because it streams)
- Requests for the Prefetch RSC now returns the correct cache headers
depending on the segment and pre-postpone state

This also enables the other pathnames in the test suites 🙌🏻 

Closes NEXT-1840
2023-12-14 13:14:06 -07:00
Zack Tanner
e8c0273677
add full PPR e2e tests (#59025)
This copies over the E2E tests that were added to `vercel/vercel` in
https://github.com/vercel/vercel/pull/10808 and
https://github.com/vercel/vercel/pull/10823, with some minor adjustments
to reflect the differences in cache behavior between start & deploy.
2023-11-29 11:34:01 -08:00
Zack Tanner
bcef6d6ab6
fix ppr test flake (#58232)
Wraps this test in a `check` since the experimental log seems to occasionally come in late ([x-ref](https://github.com/vercel/next.js/actions/runs/6805954994/job/18506429726#step:27:410))
2023-11-09 02:13:21 +00:00
Zack Tanner
fe0d947a66
ensure experimental warning shows up when using PPR (#58206)
Fixes a bug where when `config.experimental.ppr` was set, we didn't show
the proper warning indicator that the feature is experimental.
2023-11-08 17:20:02 +01:00
Zack Tanner
9aefe525bf
fix PPR build output logs (#58149)
Fixes two build output logs:

- A page that uses `generateStaticParams` & postpones should be marked as partially prerendered
- Assume pages that contain dynamic segments will postpone when PPR is enabled even though it won't be determined until request time
2023-11-07 22:09:55 +00:00
Zack Tanner
6e1eda72e1
ppr: fix fetch postpone not having correct React version (#58107)
When `patchFetch` is applied at during `buildAppStaticPaths` ([ref](030021234b/packages/next/src/build/utils.ts (L1253-L1256))), it's done so without any context of the bundled React runtime.

Since `patchFetch` will potentially postpone during static generation with PPR, it needs to be using the correct React version, otherwise `unstable_postpone` won't be available e.g. in the case of a page utilizing `generateStaticParams`.

This moves `patchFetch` into the bundled runtime so that it has the correct version of React when invoked.
2023-11-06 23:51:39 +00:00
Zack Tanner
4666e8545d
revert ppr logging changes (#57486)
need to investigate this better

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-26 00:28:24 -07:00
Zack Tanner
2c21635cf6
if there are errors during postpone, or postpone was caught, fail static generation (#57477)
Rather than sending a warning, we should fail the build if a postpone
call is caught. We should also fail the build if there are any errors
during static generation similar to the non-ppr case.

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-25 23:43:33 -07:00
Zack Tanner
0052c59022
add better messaging around wrapping postpone with try/catch (#57446)
when calls to `maybePostpone` throw but there's no postpone state, we want to handle those errors differently so that we can provide clearer messaging around how to prevent them, while still retaining any errors that were re-thrown by the user.

ex:
![CleanShot 2023-10-25 at 16 05 56@2x](https://github.com/vercel/next.js/assets/1939140/d86cce9f-f9ed-477d-8d1c-0ce7c934d073)
2023-10-26 02:50:58 +00:00
Wyatt Johnson
741a08bc25
fix: ensure generateStaticParams isn't required for PPR (#57333) 2023-10-24 14:18:11 +00:00
Wyatt Johnson
69388a52fe
Partial Prerendering (#57287)
This PR introduces a build optimization to create a "partial prerender" of the page.

1. During compilation, we create a static shell for the page using your existing Suspense boundaries. Components that can be static will be included in this static shell, leaving holes for the dynamic components.
1. Using `<Suspense />`, we can define fallbacks to be included in the partial prerender, as well as the holes for the dynamic components to stream into.

This means Next.js can initially serve a static loading skeleton, kicking off the dynamic parts in parallel. Then, the dynamic components stream in on demand. Dynamic components can use `cookies()`, `headers()`, `'cache': 'no-store'`, or `unstable_noStore()` to opt-into dynamic rendering.

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2023-10-24 01:13:05 +00:00