Skip to content

Commit 64ba501

Browse files
KyleAMathewsclaude
andcommitted
docs: fix timeout documentation and increase awaitTxId default to 15s
- Fix changeset to remove incorrect claim that TypeScript would error on old return patterns (types are generic/overridable, only runtime warns) - Update awaitTxId default timeout from 5s to 15s for more reliable sync - Fix documentation that incorrectly stated 30s default Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 46b052f commit 64ba501

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

.changeset/deprecate-handler-return-values.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
---
2-
'@tanstack/db': major
3-
'@tanstack/electric-db-collection': major
4-
'@tanstack/query-db-collection': major
2+
'@tanstack/db': minor
3+
'@tanstack/electric-db-collection': minor
4+
'@tanstack/query-db-collection': minor
55
---
66

77
**BREAKING (TypeScript only)**: Deprecate returning values from mutation handlers (`onInsert`, `onUpdate`, `onDelete`).
88

99
**What's changed:**
1010

11-
- Handler types now default to `Promise<void>` instead of `Promise<any>`
12-
- TypeScript will error on `return { refetch: false }` or `return { txid }`
13-
- Runtime still supports old return patterns for backward compatibility
11+
- Handler types now default to `Promise<void>` instead of `Promise<any>`, indicating the new expected pattern
12+
- Old return patterns (`return { refetch }`, `return { txid }`) still work at runtime with deprecation warnings
1413
- **Deprecation warnings** are now logged when handlers return values
15-
- Old patterns will be fully removed in v1.0 RC
14+
- Old patterns will be fully removed in v1.0
1615

1716
**New pattern (explicit sync coordination):**
1817

docs/collections/electric-collection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ Wait for a specific transaction ID to be synchronized:
312312
// Wait for specific txid
313313
await todosCollection.utils.awaitTxId(12345)
314314

315-
// With custom timeout (default is 30 seconds)
315+
// With custom timeout (default is 15 seconds)
316316
await todosCollection.utils.awaitTxId(12345, 10000)
317317
```
318318

packages/electric-db-collection/src/electric.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export type MatchFunction<T extends Row<unknown>> = (
9292
* - Void (no return value) - mutation completes without waiting
9393
*
9494
* The optional timeout property specifies how long to wait for the txid(s) in milliseconds.
95-
* If not specified, defaults to 5000ms.
95+
* If not specified, defaults to 15000ms.
9696
*/
9797
export type MatchingStrategy = {
9898
txid: Txid | Array<Txid>
@@ -662,12 +662,12 @@ export function electricCollectionOptions<T extends Row<unknown>>(
662662
/**
663663
* Wait for a specific transaction ID to be synced
664664
* @param txId The transaction ID to wait for as a number
665-
* @param timeout Optional timeout in milliseconds (defaults to 5000ms)
665+
* @param timeout Optional timeout in milliseconds (defaults to 15000ms)
666666
* @returns Promise that resolves when the txId is synced
667667
*/
668668
const awaitTxId: AwaitTxIdFn = async (
669669
txId: Txid,
670-
timeout: number = 5000,
670+
timeout: number = 15000,
671671
): Promise<boolean> => {
672672
debug(
673673
`${config.id ? `[${config.id}] ` : ``}awaitTxId called with txid %d`,
@@ -729,7 +729,7 @@ export function electricCollectionOptions<T extends Row<unknown>>(
729729
/**
730730
* Wait for a custom match function to find a matching message
731731
* @param matchFn Function that returns true when a message matches
732-
* @param timeout Optional timeout in milliseconds (defaults to 5000ms)
732+
* @param timeout Optional timeout in milliseconds (defaults to 15000ms)
733733
* @returns Promise that resolves when a matching message is found
734734
*/
735735
const awaitMatch: AwaitMatchFn<any> = async (

0 commit comments

Comments
 (0)