Skip to content
Source
Sign inSign up
TanStack/db

fix(electric): bound refresh wait for on-demand subsets #1575

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/1575/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 3 changed files with 140 additions and 3 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/tame-rn-live-poll-refresh.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/electric-db-collection': patch
+---
+​
+Bound the wait for Electric stream refreshes before loading on-demand subsets so native fetch implementations that do not promptly abort long polls do not keep live queries loading until the poll times out.
19 additions and 3 deletionspackages/electric-db-collection/src/electric.tsModified
View file
@@ -64,6 +64,8 @@
​
const debug = DebugModule.debug(`ts/db:electric`)
​
+const FORCE_DISCONNECT_AND_REFRESH_TIMEOUT_MS = 250
+​
/**
* Symbol for internal test hooks (hidden from public API)
*/
@@ -481,11 +483,23 @@
// When the stream is already up-to-date, it may be in a long-poll wait.
// Forcing a disconnect-and-refresh ensures requestSnapshot gets a response
// from a fresh server round-trip rather than waiting for the current poll to end.
- // If the refresh fails (e.g., PauseLock held during subscriber processing in
- // join pipelines), we fall through to requestSnapshot which still works.