Skip to content
Source
Sign inSign up
TanStack/db

Fix beforeRetry hook: scheduler not cleared after filtering transactions #1064

Closedtobacode(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/1064/headopened

Showing 3 changed files with 115 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/metal-papers-try.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/offline-transactions': patch
+---
+​
+Fix beforeRetry hook. When this hook filters out transactions during loadPendingTransactions(), those filtered transactions are removed from the outbox but remain in the scheduler. This causes them to be executed anyway, even though they were explicitly filtered out.
3 additions and 0 deletionspackages/offline-transactions/src/executor/TransactionExecutor.tsModified
View file
@@ -223,6 +223,9 @@
filteredTransactions = this.config.beforeRetry(transactions)
​
+ // Clear scheduler before reloading to ensure filtered-out transactions are removed
+ this.scheduler.clear()
+​
for (const transaction of filteredTransactions) {
this.scheduler.schedule(transaction)
107 additions and 0 deletionspackages/offline-transactions/tests/offline-e2e.test.tsModified
View file
@@ -466,4 +466,111 @@