Skip to content
Source
Sign inSign up
TanStack/db

feat(offline-transactions): add shouldRetry decision hook #1592

MergedTomasGonzalez(GitHub profile, opens in a new tab)merged 28 commits intomain fromrefs/pull/1592/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 13 changed files with 65 additions and 9 deletions (loading 10).

x
0 of 13 viewed, 13 left
11 additions and 0 deletions.changeset/offline-should-retry.mdAdded
View file
@@ -0,0 +1,11 @@
+---
+'@tanstack/offline-transactions': minor
+---
+​
+Add `OfflineConfig.shouldRetry` so an app can retry an offline transaction after
+its named mutation function rejects with a recoverable error, such as a 401.
+Return `undefined` to use the default decision. `NonRetriableError` remains
+terminal, and retry timing stays the same. The hook returns synchronously and
+applies to all named mutation functions.
+If the hook fails, the executor removes only that outbox row and rejects its
+waiters; queued transactions continue after terminal cleanup.
1 addition and 1 deletiondocs/contributing/glossary.mdModified
View file
@@ -63,7 +63,7 @@
| offline executor restart | Replacing an executor with a fresh one over retained durable outbox state. This does not restart a Collection sync run. |
| outbox replay | Resuming unfinished durable offline transaction work, including outbox reconciliation and permitted mutation execution or terminal-phase deletion. This is separate from truncate replay and oracle replay. |
| `deletion-pending` | The mutation function fulfilled; only acknowledged outbox deletion remains before caller success. An offline executor restart must not call the mutation function again. |
-| `rejection-pending` | The mutation function failed permanently; the caller rejects with that failure. An offline executor restart removes the marked row without calling the mutation function again or restoring its optimistic state. |
+| `rejection-pending` | The named mutation function failed and the executor chose terminal rejection, or the retry decision hook failed. The caller rejects with that failure. An offline executor restart removes the marked row without calling the mutation function again or restoring its optimistic state. |
​
## Demand and pagination terms
​