cloudflare / cloudflare/vinext

App Router: `"use cache"` build-time, private, and route-handler revalidate broken

Open
#1,453 0 comments 0 reactions 0 assignees View on GitHub
adapter-api-e2e help wanted
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

> *This issue was created by an agent analysing CI failures from the [Next.js Deploy Suite](https://github.com/cloudflare/vinext/actions/runs/26282973805) (vinext `main` vs Next.js `v16.2.6`, 2026-05-22).*

## Problem

Several `"use cache"` behaviors are broken: (1) Functions reached via prerender / metadata route handler / inline server action are evaluated at runtime instead of build time, so sitemap/robots/manifest emit `sentinel=runtime` instead of `sentinel=buildtime`. (2) `"use cache: private"` does not expose cookies/searchParams to the cached function. (3) Prerendered route handlers using `'use cache'` cannot be revalidated via `revalidatePath`/`revalidateTag`. (4) A server action that depends on a nested cached function passed as a prop never produces a clickable hydrated button.

```
- https://acme.com?sentinel=buildtime
+ https://acme.com?sentinel=runtime
```

```
use cache: private - #test-cookie / #search-param selectors remain hidden
```

```
Expected: not "2026-05-22T10:49:42.408Z" // route handler revalidate did not change timestamp
```

## Estimated Impact

~9 test failures across the deploy suite.

## Affected Test Suites

- `test/e2e/app-dir/use-cache-metadata-route-handler/use-cache-metadata-route-handler.test.ts` (4 failures)
- `test/e2e/app-dir/use-cache-private/use-cache-private.test.ts` (2 failures)
- `test/e2e/app-dir/cache-components/cache-components.server-action.test.ts`
- `test/e2e/app-dir/use-cache-route-handler-only/use-cache-route-handler-only.test.ts`
- `test/e2e/app-dir/use-cache-with-server-function-props/use-cache-with-server-function-props.test.ts`

## Recommendation

1. **Reproduce first in vinext's own test suite.** Cover the four cases independently: (a) `"use cache"` in a metadata route handler, (b) `"use cache: private"` reading cookies, (c) revalidating a `'use cache'` route handler, (d) a nested cached function passed as a prop into a server action.

2. **Study Next.js `"use cache"` evaluation.** Search `.nextjs-ref/packages/next/src/server/use-cache/` and `.nextjs-ref/packages/next/src/build/` for buildtime evaluation, private inputs, route-handler revalidation, and nested action serialization.

3. **Wire `"use cache"` into the prerender pipeline.** When prerendering metadata routes, sitemaps, robots, and inline server actions, the cache function should be evaluated against the prerender execution context so it sees `buildtime` sentinels and produces stable values.

4. **Thread cookies/searchParams into private cache scopes.** `"use cache: private"` must bind to the request scope so `cookies()` / `searchParams` read at request time.

5. **Make route-handler revalidation trigger invalidation.** `revalidatePath`/`revalidateTag` must evict cached route-handler responses just like cached page responses.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.