Stale Response Overwrites Draft Autosave
Level 2 · node · Concurrency · Asynchronous response ordering error
Scenario
A post editor autosaves the draft after each edit and applies the saved response from the server to its local store. When a user makes two edits quickly, operations reports show that the server can contain the newer content while the screen later reverts to the older content. The frontend action, draft store, API client, and server repository are separated, and request response times can differ.
Requirements
- After consecutive edits, the UI store must keep the content from the most recently started save request - A late response from an older save request must not overwrite the latest local draft - A single save request applies the id and content returned by the server normally - The server repository keeps the content from the request it processed last - When no save fails, every saveDraft call returns a completed result
Acceptance criteria
- A single autosave applies the server response to the store
- When two save responses arrive out of order, the store keeps the content from the latest request
- A late response from an older request does not change the latest store state
- Each autosave call returns a completed result
- At the end of a test, the server repository and store states can each be queried