Optimistic mutation does not roll back on failure
An item added optimistically stays on screen after the remote write returns HTTP 500. The list and the server disagree, and nothing tells the user.
同一個缺陷,每一個視角
- 使用者
The item is on the list. Reload and it is gone. Nothing said the save failed.
- 執行期
The mutation promise rejects. The rejection is caught and logged, and the local store is never touched again.
- 架構
Local state was written before the remote write was known to succeed, and no compensating action exists for the failure branch.
- AI 生成
The generated handler covers the success path in full and the failure path only as a log line — the shape you get when the prompt describes what should happen and not what happens when it does not.
判斷軌跡
- 條件 · 依賴any-async-transport2026-08-01 12:30 → 至今信心 0.71
- 何事 · 使用者stale-ui2026-08-01 12:02 → 至今信心 0.99
- 何處 · 架構transaction-boundary2026-08-01 12:24 → 至今信心 0.84
- 為何 · 執行期race-condition2026-08-01 12:05 → 2026-08-01 12:22信心 0.42已被取代
- 為何 · AI 生成omitted-failure-path2026-08-01 12:22 → 至今信心 0.92
觀察記錄
- 2026-08-01 12:00已捕捉
HTTP 500 reproduced with the optimistic item still on screen.
- 2026-08-01 12:05調查中
First reading: a race between two writes.
- 2026-08-01 12:20已重現
Single-write reproduction refutes the race.
- 2026-08-01 12:22已定位
The failure branch never restores state. Classification revised.
- 2026-08-01 12:28已修補
First patch rejected; second attaches a rollback.
- 2026-08-01 12:33待驗證
Regression test attached.
- 2026-08-01 12:35已驗證
pre failed, post passed.
可執行見證
Currently contested by BC-0005: the gate test fails after a framework upgrade.
假設
- refuted
Two concurrent writes interleave and the later one wins.
Reproduced with a single write. The failure needs no concurrency at all.
- supported
The error handler never restores the pre-mutation state.
證據
- reproduction · 2026-08-01 12:02
Forced POST /todos to return HTTP 500. The optimistic row stayed visible; a reload removed it.
- execution · 2026-08-01 12:20
Single sequential write, no concurrency. Same outcome — refutes the race hypothesis.
- test_result · 2026-08-01 12:33
Regression test fails against pre and passes against post.
修補
- rejected
Disable the optimistic update entirely.
Rejected: removes the behaviour instead of completing it, and the latency it hid is real.
- accepted
Restore the captured previous state inside the async error handler.
關聯
- manifested_asBE-0001
- same_root_asBU-0003