next.js
6c70938c - [ppr] RDC for RSCs (#79638)

Commit
193 days ago
[ppr] RDC for RSCs (#79638) This pull request introduces support for handling postponed state in dynamic React Server Components (or RSC) requests, enabling the use of the encoded Resume Data Cache (or RDC). The changes include adjustments to the server logic to better manage dynamic responses and improve caching behavior for such requests. This also updates the incremental cache to also add to the RDC when it's fetching already generated entries. This pull request introduces changes to support dynamic React Server Components (RSC) requests by enabling the use of postponed state and improving cache handling. It also includes updates to error handling, testing utilities, and incremental caching logic. ### Enhancements for Dynamic RSC Requests * Added support for resuming renders with postponed data from the cache for dynamic RSC requests, leveraging the `IncrementalCacheKind.APP_PAGE` cache type. This ensures efficient reuse of cached data when available. (`packages/next/src/server/base-server.ts`, [[1]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3097-R3139) [[2]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3262-R3294) * Updated cache control logic to handle dynamic RSC requests more effectively, ensuring they are not cached when containing dynamic content. (`packages/next/src/server/base-server.ts`, [packages/next/src/server/base-server.tsL3526-R3550](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3526-R3550)) ### Improvements to Incremental Caching * Introduced a `checkTags` method in the `IncrementalCache` class to determine if a tag has been revalidated, preventing stale data from being returned. (`packages/next/src/server/lib/incremental-cache/index.ts`, [packages/next/src/server/lib/incremental-cache/index.tsR599-R627](diffhunk://#diff-c990316f5df4319261936cd61b07566c5e12cd7e68c9e92f6da38a190a639154R599-R627)) * Refactored logic to store prerender resume data in the cache for better performance and reliability. (`packages/next/src/server/lib/incremental-cache/index.ts`, [packages/next/src/server/lib/incremental-cache/index.tsL442-R461](diffhunk://#diff-c990316f5df4319261936cd61b07566c5e12cd7e68c9e92f6da38a190a639154L442-R461)) ### Testing Updates * Updated E2E tests in `app-action.test.ts` to use modern `fs/promises` and `node:path` modules, improving readability and consistency. (`test/e2e/app-dir/actions/app-action.test.ts`, [test/e2e/app-dir/actions/app-action.test.tsL11-R14](diffhunk://#diff-b3bc78ed83df32c7d5afa3d352038f8afd7eb37027be87ca22bac3d3cb33657aL11-R14)) * Refactored test assertions to ensure dynamic RSC behavior and revalidation logic are correctly validated. (`test/e2e/app-dir/actions/app-action.test.ts`, [[1]](diffhunk://#diff-b3bc78ed83df32c7d5afa3d352038f8afd7eb37027be87ca22bac3d3cb33657aR543-L546) [[2]](diffhunk://#diff-b3bc78ed83df32c7d5afa3d352038f8afd7eb37027be87ca22bac3d3cb33657aL1564-R1589)
Author
Parents
Loading