Skip to content

Prevent older preloads from overwriting mutations - #4329

Open
ryux1 wants to merge 1 commit into
vercel:mainfrom
ryux1:fix/preload-mutation-order
Open

Prevent older preloads from overwriting mutations#4329
ryux1 wants to merge 1 commit into
vercel:mainfrom
ryux1:fix/preload-mutation-order

Conversation

@ryux1

@ryux1 ryux1 commented Sep 7, 2026

Copy link
Copy Markdown

What

  • discard an existing keyed preload when a newer mutation starts
  • add a regression covering preload → local mutation → later mount

Why

A keyed mutation with revalidation disabled can leave an older response in PRELOAD. When the hook mounts later, it consumes that response and overwrites the newer cached value. Invalidating the old preload makes the mount issue a fresh request instead.

Fixes #4327

Testing

  • pnpm format:check
  • pnpm build
  • pnpm types:check
  • pnpm lint
  • pnpm test-typing
  • pnpm test --runInBand (35 suites, 389 passed, 5 skipped)
  • pnpm test:build --runInBand (35 suites, 389 passed, 5 skipped)
  • npm pack --ignore-scripts
  • pnpm attw --pack .

A preloaded response can outlive a newer keyed mutation when revalidation is disabled. A later mount then consumes that older response instead of issuing a fresh request.

Discard the key’s existing preload at mutation start and cover the ordering with a regression that distinguishes the obsolete response from the subsequent fetch.
@ryux1
ryux1 requested review from huozhi and shuding as code owners September 7, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Older Preload state overwrites a more recent mutated cached value

1 participant