Skip to content

[dynamicIO] Avoid timeout errors with dynamic params in "use cache" #78882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9b2e71d
Make `"use cache"` function that accesses cookies dynamic
unstubbable Apr 17, 2025
64b1763
Unflake test
unstubbable Apr 20, 2025
476cf3d
Return a discriminated object instead of a tuple
unstubbable Apr 21, 2025
ceb798b
Include accessed cookies in cache key
unstubbable Apr 21, 2025
47776a8
Add undefined cookies to route prerender stores
unstubbable Apr 21, 2025
4b290df
Fix compiler errors related to RDC in test files
unstubbable Apr 21, 2025
2d155cc
Handle key changes in RDC
unstubbable Apr 22, 2025
049f29b
Include accessed cookies in cache key
unstubbable Apr 23, 2025
fbd133f
Add `keys` method to `UseCacheCacheStore`
unstubbable Apr 24, 2025
65fa2d7
Properly handle asynchronicity in `UseCacheCacheStore`
unstubbable Apr 24, 2025
b89a308
Disable mangling in test to debug failures
unstubbable Apr 24, 2025
c4baec1
Add `renderContext` to `UseCacheStore`
unstubbable Apr 25, 2025
deb49f4
Cleanup debug logs
unstubbable Apr 25, 2025
ed11343
Remove rogue `console.log` statement
unstubbable Apr 25, 2025
cb04c10
Remove debug logs
unstubbable Apr 25, 2025
a6928ba
Rename `doNotThrowOnEmptyStaticShell` to `allowEmptyStaticShell`
unstubbable May 6, 2025
602b7c8
Add test cases
unstubbable May 6, 2025
16bcdde
Set `allowEmptyStaticShell` during revalidation
unstubbable May 6, 2025
4b21ef8
Add `allowEmptyStaticShell` to prerender store
unstubbable May 6, 2025
a4adff8
Add `allowEmptyStaticShell` to `UseCacheRenderContextPrerender`
unstubbable May 6, 2025
a359660
Allow cache timeout due to awaiting fallback params
unstubbable May 6, 2025
a18d6e4
Revert cookies-related changes
unstubbable May 6, 2025
ce30f8d
Delete debug log
unstubbable May 6, 2025
bf9aa93
Revert changes in RDC tests
unstubbable May 6, 2025
27165a8
Revert changes in `use-cache` test suite
unstubbable May 6, 2025
4014dd0
Delete `use-cache-cookies` test suite
unstubbable May 6, 2025
a41be37
Remove `cookies` reference in route module
unstubbable May 6, 2025
a415ed5
Remove `cookies` from work unit stores
unstubbable May 6, 2025
f9108a7
Revert changes in `use-cache` test fixtures
unstubbable May 6, 2025
9d62611
Partially revert the revert in `cookies.ts`
unstubbable May 6, 2025
7d26d23
Revert adding `waitUntil` option
unstubbable May 6, 2025
0ea8f11
Update prerender manifest snapshots
unstubbable May 6, 2025
f25680c
Fix compiler error in test file
unstubbable May 6, 2025
545c9b6
Increase test setup timeout
unstubbable May 6, 2025
b064f0e
Fix test expectation for deploy mode
unstubbable May 7, 2025
bf04166
Don't abort on fallback params access if `allowEmptyStaticShell` is f…
unstubbable May 7, 2025
6ef003f
Introduce `DynamicAccessStorage`
unstubbable May 11, 2025
08e2bfd
Non-page `"use cache"` functions accessing fallback params make them …
unstubbable May 11, 2025
8407901
Remove obsolete `UseCacheRenderContext`
unstubbable May 11, 2025
af47843
Remove obsolete `allowEmptyStaticShell` from build output
unstubbable May 11, 2025
1c005a2
Remove `allowEmptyStaticShell` from `PrerenderStoreModern`
unstubbable May 11, 2025
728d588
Generalize error message
unstubbable May 11, 2025
d1ae3cf
Revert changes in `packages/next/src/server/base-server.ts`
unstubbable May 11, 2025
cc42a27
Remove `allowEmptyStaticShell` from test fixture
unstubbable May 11, 2025
99e7154
Revert "Update prerender manifest snapshots"
unstubbable May 11, 2025
6723ee1
Remove `options.timeout` from `test/lib/e2e-utils/index.ts`
unstubbable May 11, 2025
ba9f760
Remove unused cache kind argument
unstubbable May 11, 2025
9e5eb78
Make properties in `GenerateCacheEntryResult` readonly
unstubbable May 11, 2025
23fc14d
Move `dynamicAccessAbortSignal` declaration closer to usage
unstubbable May 11, 2025
23acd9b
Fix minor issues in `"use cache"` wrapper
unstubbable May 11, 2025
5e340a4
Add changeset
unstubbable May 17, 2025
9c19231
Support instrumented `params.then/catch/finally`
unstubbable May 19, 2025
95d7c23
Avoid `HANGING_PROMISE_REJECTION` being logged
unstubbable May 20, 2025
2b80098
Revert changes in `headers`, `cookies`, and `searchParams`
unstubbable May 20, 2025
ec2edd5
Add more test cases
unstubbable May 20, 2025
f214655
Use "inner"/"outer" wording
unstubbable May 20, 2025
9b7fd3f
Update `errors.json`
unstubbable May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tricky-planes-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"next": patch
---

[dynamicIO] Avoid timeout errors with dynamic params in `"use cache"`
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
// singleton modules should always use "*.external" instead of "*-instance"
"packages/next/src/server/app-render/action-async-storage-instance.ts",
"packages/next/src/server/app-render/after-task-async-storage-instance.ts",
"packages/next/src/server/app-render/dynamic-access-async-storage-instance.ts",
"packages/next/src/server/app-render/work-async-storage-instance.ts",
"packages/next/src/server/app-render/work-unit-async-storage-instance.ts",
"packages/next/src/client/components/segment-cache-impl/*"
Expand Down
4 changes: 3 additions & 1 deletion packages/next/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,5 +682,7 @@
"681": "Dynamic imports should not be instrumented in the edge runtime, because `dynamicIO` doesn't support it",
"682": "\\`experimental.ppr\\` can not be \\`%s\\` when \\`experimental.dynamicIO\\` is \\`true\\`. PPR is implicitly enabled when Dynamic IO is enabled.",
"683": "The \\`compiler.define\\` option is configured to replace the \\`%s\\` variable. This variable is either part of a Next.js built-in or is already configured.",
"684": "The \\`compiler.defineServer\\` option is configured to replace the \\`%s\\` variable. This variable is either part of a Next.js built-in or is already configured."
"684": "The \\`compiler.defineServer\\` option is configured to replace the \\`%s\\` variable. This variable is either part of a Next.js built-in or is already configured.",
"685": "Accessed fallback \\`params\\` during prerendering.",
"686": "Expected clientReferenceManifest to be defined."
}
3 changes: 1 addition & 2 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2683,8 +2683,7 @@ export default async function build(
_isDynamicError: isDynamicError,
_isAppDir: true,
_isRoutePPREnabled: isRoutePPREnabled,
_doNotThrowOnEmptyStaticShell:
!route.throwOnEmptyStaticShell,
_allowEmptyStaticShell: !route.throwOnEmptyStaticShell,
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const browserNonTranspileModules = [
const precompileRegex = /[\\/]next[\\/]dist[\\/]compiled[\\/]/

const asyncStoragesRegex =
/next[\\/]dist[\\/](esm[\\/])?server[\\/]app-render[\\/](work-async-storage|action-async-storage|work-unit-async-storage)/
/next[\\/]dist[\\/](esm[\\/])?server[\\/]app-render[\\/](work-async-storage|action-async-storage|dynamic-access-async-storage|work-unit-async-storage)/

// Support for NODE_PATH
const nodePathList = (process.env.NODE_PATH || '')
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/export/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ async function exportPageImpl(
// the renderOpts.
_isRoutePPREnabled: isRoutePPREnabled,

// Configure the rendering of the page not to throw if an empty static shell
// is generated while rendering using PPR.
_doNotThrowOnEmptyStaticShell: doNotThrowOnEmptyStaticShell = false,
// Configure the rendering of the page to allow that an empty static shell
// is generated while rendering using PPR and Dynamic IO.
_allowEmptyStaticShell: allowEmptyStaticShell = false,

// Pull the original query out.
query: originalQuery = {},
Expand Down Expand Up @@ -266,7 +266,7 @@ async function exportPageImpl(
// If it's static, then it won't affect anything.
// If it's dynamic, then it can be handled when request hits the route.
serveStreamingMetadata: true,
doNotThrowOnEmptyStaticShell,
allowEmptyStaticShell,
experimental: {
...input.renderOpts.experimental,
isRoutePPREnabled,
Expand Down
Loading
Loading