Recover Create Requests After an Uncertain Result

A Create button can get an error even when the database has already saved the record. The response might be lost, interrupted or unreadable. From the browser’s point of view, the result is uncertain. Sending a new request with a new identity can create a second record rather than repair the first attempt.
The Dink Slot owner workspace added a creation ledger and a recovery action for that case. It’s part of an owner-only beta, with public customer booking and payments still disabled. The work gives a concrete example of making uncertainty visible instead of treating every missing response as a failed write.
Give the attempt a stable identity
The browser creates an opaque key for a new branch or court. It sends that key with the creation request in the Idempotency-Key header. The server combines the key with the current actor and record kind when identifying the command.
That scope matters. A key for one owner’s branch creation isn’t an unrestricted reference to another owner’s operation. The recovery route still requires owner authentication and a valid request context. The key helps identify a command; it doesn’t grant permission to read the result.
The UI keeps the same key when retrying the same creation. Generating a fresh key on every click would remove the connection between attempts. A request identifier is only useful for recovery when both sides keep using the identity of the operation they want to recover.
Commit the result and its receipt together
The storage change adds a command table with a unique key hash, a payload hash and the resulting record identifier. A creation transaction claims that command before inserting the record. It also records a minimal history event and writes the result identifier into the command row.
Those writes commit together. If adding the history event fails, the transaction rolls back the record and command claim too. Otherwise the application could have a record without the receipt needed to find it, or a receipt pointing to something that never committed.
A repeated request with the same key and payload returns the original identity. Reusing the key with different details is a conflict. The code doesn’t guess whether a changed court name means the same operation or a new one. It asks the owner to recover the original result first.
Keep the original payload for a same-page retry
The editor freezes the create body when the first attempt starts. Its explicit Retry same creation action uses that body and the original key. Fields are disabled while the result is uncertain, which helps avoid presenting a changed form as if it were a safe replay of the earlier command.
A normal validation error is handled differently. When the server rejects the input before accepting the creation, the editor can let the owner correct it. Uncertain transport results and definite field errors shouldn’t lead to the same next action.
That distinction is worth carrying into error types. A message saying something went wrong doesn’t tell the interface whether it can safely unlock every field and send a different request. The recovery controls need enough information to choose a sensible path.
Persist the key without persisting the form
The implementation stores the opaque pending key in sessionStorage. It doesn’t put contact details, authentication data or the whole draft there. While the current page remains open, the frozen body is kept in memory. After a reload, the key can still support a lookup for the committed result.
This deliberately limits what survives. A reload isn’t a promise to restore every typed field, and unavailable browser storage leaves only the in-memory recovery path. It isn’t durable offline draft storage.
The editor offers recovery when it finds a pending creation key. The server’s command lookup returns the canonical record, so the browser can open what actually exists. A missing result keeps the original key relevant rather than proving that a new identity is safe.
Offer recovery before another write
The workspace includes Recover original record and Check the catalog actions. A same-page retry is explicit, using the frozen details. The API documentation says not to automatically replay mutations after an uncertain result.
That gives the owner a way to ask what happened without making another change. Recovery and retry may eventually reach the same record, but they’re different operations. A read can establish the current result before the interface asks someone to choose another write.
Keep the wording tied to what the application knows. If the request may have committed, say so plainly. A generic Try again button can imply that nothing happened when the server has already done the work.
Test the receipt as part of the operation
The added storage tests repeat a creation with the same input and key, then check for one record identity and one history event. Another changes the payload under the same key and expects a conflict. Recovery is checked using the command’s actor and kind.
A forced history-write failure verifies that the record, claim and history all roll back. These tests cover specific storage behavior. They don’t prove every possible network failure.
For further integration checks, I’d commit a real operation, withhold its normal success handling, reload with the saved key and recover it. Keep that description separate from claiming a deterministic broken TCP connection. The useful guarantee is narrower and practical: an uncertain response doesn’t force the owner to start creation from scratch.
Written by
Adrian Saycon
A developer with a passion for emerging technologies, Adrian Saycon focuses on transforming the latest tech trends into great, functional products.



