Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/guides/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,21 @@ try {
}
```

> [!IMPORTANT]
> **Always use `tx.isPersisted.promise`, not `tx.isPersisted`.** The `isPersisted` property is a `Deferred` object, not a `Promise`. Since `Deferred` does not implement a `.then()` method, `await tx.isPersisted` resolves immediately to the `Deferred` object itself — it does **not** wait for the transaction to persist.
>
> This is a silent bug that TypeScript will not catch, because `await` accepts any value.
>
> ```typescript
> // ❌ BUG: resolves immediately — does not wait for persistence
> await tx.isPersisted
>
> // ✅ CORRECT: waits for the transaction to complete or fail
> await tx.isPersisted.promise
> ```
>
> If you forget `.promise`, your UI may clear forms, navigate, or show success messages before the server has confirmed the write. If the server then rejects the mutation, the optimistic state rolls back silently with no error handling.

### State Transitions

The normal flow is: `pending` → `persisting` → `completed`
Expand Down