Skip to content

fix: populate LRU for batched invocations in minimal mode response cache#93699

Open
craigandrews wants to merge 1 commit intovercel:canaryfrom
craigandrews:craigandrews/ensure-isr-lru-is-written-if-requests-collapsed
Open

fix: populate LRU for batched invocations in minimal mode response cache#93699
craigandrews wants to merge 1 commit intovercel:canaryfrom
craigandrews:craigandrews/ensure-isr-lru-is-written-if-requests-collapsed

Conversation

@craigandrews
Copy link
Copy Markdown

@craigandrews craigandrews commented May 8, 2026

Summary

When multiple minimal mode revalidation invocations (different x-invocation-id) arrive concurrently for the same path, the batcher correctly deduplicates them into a single render. However, the LRU is only populated for the invocation that actually rendered. Batched invocations never execute the work function where the LRU write happens. This causes follow-up requests to miss the LRU and trigger a new render, creating a cascade of redundant renders under load.

The fix writes the render result to the LRU for each batched invocation's ID after the batcher promise resolves, so follow-up requests find their entry without re-rendering.

Test Plan

  • Unit test: concurrent invocations with different invocationID values verify only one render executes and follow-up requests hit the LRU

@craigandrews craigandrews requested a review from ztanner May 8, 2026 16:27
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Failing test suites

Commit: 2091e64 | About building and testing Next.js

pnpm test-start test/e2e/app-dir/prefetch-true-instant/prefetch-true-instant.test.ts (job)

  • prefetch={true} with instant route > does not include dynamic content in the prefetch when the target route has instant (DD)
Expand output

● prefetch={true} with instant route › does not include dynamic content in the prefetch when the target route has instant

thrown: "Exceeded timeout of 60000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

  50 |       }
  51 |
> 52 |       const result = Reflect.apply(target, thisArg, args)
     |                              ^
  53 |       return typeof result === 'function' ? wrapJestTestFn(result) : result
  54 |     },
  55 |     get(target, prop, receiver) {

  at Object.apply (lib/e2e-utils/index.ts:52:30)
  at it (e2e/app-dir/prefetch-true-instant/prefetch-true-instant.test.ts:14:3)
  at Object.describe (e2e/app-dir/prefetch-true-instant/prefetch-true-instant.test.ts:5:1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant