DEV Community

Cover image for Recover a WebMCP Update After Its Response Disappears

Recover a WebMCP Update After Its Response Disappears

Raju Dandigam on November 15, 2026

The browser showed JFK. The database already contained BOS. That was the state of a synthetic trip after I deliberately hid the successful respons...
Collapse
 
rohail_rohail_422ad9a1155 profile image
Rohail Rohail •

This is really interesting! I haven't worked with WebMCP much yet, but losing a response mid-update sounds so frustrating. Thanks for sharing how you recovered it, this will definitely help beginners like me. Did it happen only once or is it a common issue?

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@rohail_rohail_422ad9a1155 Good question. This was one deliberately injected lost response, not a production incident. The same uncertainty can happen with an ordinary network timeout after a server commits. The command ID and receipt lookup let the client check the original update before it considers another write.

Collapse
 
vmodal_ai profile image
vmodal_ai •

looks good , we will try to integrate webMCP

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@vmodal_ai If you try WebMCP in your workflow, I'd start with one read-only tool, then test a mutation where the server commits but the browser loses the response. A stable command ID and read-only recheck path let the app recover without repeating the write or erasing unsaved form edits. What workflow are you considering?

Collapse
 
dafili profile image
Renhua Wei •

You close the hole at the API and reopen it at the storage layer: if the receipt row is written in a second statement after the PATCH commits, a crash in between leaves revision 3 committed with nothing to look up, and your client reads that 404 as "never applied" and retries into a double apply. Insert the receipt inside the same transaction as the revision bump, and make the lookup answer with a terminal row or 410 Gone instead of 404, with retention at least as long as your max client retry window - 24h of receipt rows is cheaper than one reconciliation job.

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@dafili You are right to press on the storage boundary. “Same server-side workflow” is not enough evidence that the revision update and receipt insert commit atomically; the crash-between-statements case needs its own test. A missing receipt must remain ambiguous, including after retention expires, rather than authorize a replay. I would make expiry explicit in the lookup and require reconciliation against authoritative state before another write.

Collapse
 
dafili profile image
Renhua Wei •

Agreed on making expiry explicit, and I'd push it to three outcomes rather than two: receipt present, unknown-expired, absent — only absent may proceed to a write, otherwise retention expiry quietly becomes the replay path you just closed. The test I'd write for the crash window is SELECT pg_terminate_backend(pg_backend_pid()) right after the revision UPDATE and before the receipt INSERT, then retry the same key and assert it returns the stored revision with zero new writes. If clients need the ambiguity visible, return that stored revision with a reconciled=false flag instead of a 409.

Collapse
 
mp3sss31 profile image
mp3sss •

The 'unknown, not failed' distinction is exactly the right frame: a dropped 200 after commit leaves the client unable to claim either outcome, so replaying the write without an idempotency key risks double-applying the mutation. The recovery path you chose — a read-back against the stable command ID and expected revision instead of another PATCH — keeps the operation idempotent and lets the UI reconcile from server state rather than guess. In a desktop/Electron-style app the same pattern applies to IPC writes to the main process: persist an outbound command with its own id, and on reconnect or reload reconcile by reading current state before re-sending, rather than assuming a lost reply means a lost action.

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@mp3sss31 The IPC comparison is useful. Across a renderer reload, I would persist the original command ID together with its draft ID and intended revision, then query the main process for that command before considering any resend. A local “request timed out” flag is only evidence about the reply path; it says nothing about whether the write landed.

Collapse
 
innokentyb profile image
Kent Bodrov •

The separation between the saved server state and the person’s newer unsaved edit is particularly useful. What happens if the command receipt has expired before the client reconnects? A missing receipt would not prove the write failed, so I’d keep the result unresolved and avoid a fresh mutation until a person or an independent record can reconcile it. Does the interface expose that boundary explicitly?

Collapse
 
raju_dandigam profile image
Raju Dandigam Google Developer Experts •

@innokentyb Yes. In the tested path, an unavailable lookup leaves the editor at OUTCOME_UNKNOWN and blocks a fresh mutation. Receipt expiry is a separate case the demo has not exercised. I would show it as “reconciliation required,” keep the unsaved human edit visible, and avoid treating a missing receipt as proof of failure. An explicit expired result would help the UI distinguish that from a receipt that has not appeared yet.