fix(examples): forward abort signal in tanstack-db-web-starter Electric proxy - #4768
Open
Jaime02 wants to merge 1 commit into
Open
fix(examples): forward abort signal in tanstack-db-web-starter Electric proxy#4768Jaime02 wants to merge 1 commit into
Jaime02 wants to merge 1 commit into
Conversation
…ic proxy `proxyElectricRequest` called `fetch(originUrl)` without the incoming request's `AbortSignal`, so a client disconnect left the upstream call to Electric with no cancellation path. For `live=true` long-polls that holds a connection and a fetch slot for the full long-poll timeout (~20s measured) after the client is gone, which compounds with the 256-concurrent-fetch cap that skills/electric-proxy-auth/SKILL.md documents. Forward the signal through to the upstream fetch and pass `request.signal` at the three call sites. The parameter is optional, so existing callers are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Jaime02
marked this pull request as ready for review
August 22, 2026 17:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
proxyElectricRequestcallsfetch(originUrl)without forwarding the incoming request'sAbortSignal. When a client goes away mid-request — a page reload, a navigation, a closed tab — the proxy's upstream call to Electric has no cancellation path and keeps running to completion.For
live=truelong-polls that is the full long-poll timeout. Measured against a local Electric (electricsql/electric:latest, default settings), proxying through a TanStack Start route:Each abandoned live request pins one upstream connection and one
fetchslot for ~20s after the client that wanted it is already gone.This compounds with the concurrency limit that
skills/electric-proxy-auth/SKILL.mdalready documents:A page holding ~10 shapes leaks ~10 slots per reload, each for ~20s. Roughly 26 abandoned page loads inside one 20-second window is enough to exhaust the pool — easily reached when a deploy causes many connected clients to reconnect at once. The symptom is the latency spike the skill describes; the missing signal is one of its causes.
Change
Forward the request's
AbortSignalto the upstreamfetch:and pass
request.signalat the three call sites (todos,users,projects).The parameter is optional, so this is source-compatible with any existing caller.
Same pattern elsewhere
I kept this PR to the one starter to stay reviewable, but the same
fetch(originUrl)without a signal appears in:examples/tanstack-db-expo-starter/api/index.ts(~line 138)website/docs/sync/guides/auth.md(proxy examples around lines 152, 407, 414, 624, 644)packages/typescript-client/skills/electric-proxy-auth/SKILL.md(~line 51)