Repository navigation
Description
Describe the Bug
When an editor changes two fields while an autosave is still on its way, the first of them goes back to its old value, and a later autosave stores that old value. The change is lost without notice. This happens on any slow server or connection.
The autosave answer is built from the form state that was sent with the request, and mergeServerFormState merges it into the current client state:
- Values. On autosave (
acceptValues: { overrideLocalChanges: false }), a value is skipped only when the client field hasisModifiedset. TheUPDATEaction of the field reducer removesisModifiedfrom every other field whenever a field changes. So only the field changed last is protected. After two quick changes (A, then B) during a running autosave, A is back on its old value once the autosaves that follow are done. - Server-computed state.
passesCondition,rows(includingcollapsed) andvalid/errorMessageare always taken from the answer. A stale answer shows the fields for an old condition, or marks a field valid again right after a save returned an error for it. - No follow-up request.
MERGE_SERVER_STATEsetsprevStateRef.currentto the merged state, so the debouncedonChangesees no change and doesn't send the form-state request that would correct point 2.
The reproduction covers point 1. We saw points 2 and 3 in our own project: after a quick change of a select, the fields for its old value stayed visible; and a server-side validation error disappeared when a form-state answer from typing came back after Save's 400 (the error toast stayed).
Expected: an answer doesn't overwrite values that changed after its request was sent, and server-computed state from a stale answer is replaced by a fresh request.
Possibly related: #15719 (autosave reverts the link type in the rich text link drawer).
Link to the code that reproduces this issue
Reproduction Steps
The repository has one Playwright test (tests/stale-autosave.e2e.spec.ts) on a posts collection with versions.drafts.autosave (interval: 100) and two fields, color (radio, default Light) and size (select, default Small).
docker compose run --rm test
# or: npm install && npx playwright install chromium && npx playwright testWhat the test does:
- Open a post in the admin panel. Autosave requests are held back for 2 s to stand in for a slow server.
- Edit the title. An autosave is sent with Color = Light.
- While it is on its way, set Color to Dark, then Size to Large.
- Wait until the autosaves and form-state requests are done.
Result: Color is back on Light in the form, and the saved draft has color: 'light'. Size keeps Large.
Error: expect(locator).toBeChecked() failed
Locator: getByRole('radio', { name: 'Dark', exact: true })
Expected: checked
Received: unchecked
With only one change during the autosave (skip the Size change), Color stays Dark.
Which area(s) are affected?
area: ui
Environment Info
Binaries:
Node: 26.13.0
npm: 11.20.0
Relevant Packages:
payload: 3.93.0
next: 16.3.5
@payloadcms/db-sqlite: 3.93.0
@payloadcms/drizzle: 3.93.0
@payloadcms/graphql: 3.93.0
@payloadcms/next/utilities: 3.93.0
@payloadcms/translations: 3.93.0
@payloadcms/ui/shared: 3.93.0
react: 19.2.6
react-dom: 19.2.6
Operating System:
Platform: linux (Docker, mcr.microsoft.com/playwright:v1.64.1-noble)
Arch: x64
Also seen with 3.92.0 in a production project (Postgres).
Activity
fix(ui): prevent stale responses from overwriting form state (payload…
github-actions commentedon Nov 24, 2026
🚀 This is included in version v4.0.0-beta.12