Skip to content

Reconnect when the HTTP sync stream goes silent - #1224

Open
SnakeO wants to merge 1 commit into
powersync-ja:mainfrom
SnakeO:fix-1208-silent-stream
Open

SnakeO wants to merge 1 commit into
powersync-ja:mainfrom
SnakeO:fix-1208-silent-stream

Conversation

@SnakeO

@SnakeO SnakeO commented Nov 22, 2026

Copy link
Copy Markdown

closes #1208

the HTTP sync stream only had a timeout until the response started (connectTimeoutMs). after that, a stream that died without closing (network change, proxy or NAT dropping it) kept the client connected with nothing arriving, until something else made it reconnect.

the service sends a keepalive line every 20 seconds, so fetchStreamRaw now fails a read that gets nothing for 30 seconds and cancels the response. the error takes the normal path: it shows up as downloadError, the status goes to disconnected, and the client reconnects after retryDelayMs. 30 seconds is what the WebSocket path already uses (SOCKET_TIMEOUT_MS).

the timer only runs while a read is waiting for data, so a client thats slow to process lines doesn't trip it.

I kept it a constant like the WebSocket one. if you'd rather have it configurable (the issue mentions that,) I can add a SyncOptions field next to connectTimeoutMs.

tests, in packages/node/tests/sync.test.ts with fake timers like the WebSocket timeout test:

  • a stream that goes quiet is still connected at 29 seconds, then reports the error, disconnects and opens a second stream. this one fails on main
  • a stream that gets a keepalive every 20 seconds stays on its first connection for 100 seconds

ran the common, shared-internals, node and web tests locally on Node 26 (and node's on Node 24), all passing. there's a patch changeset for @powersync/shared-internals

The HTTP sync stream only had a timeout until the response started. A
stream that died without closing (a network change, a proxy or NAT
dropping it) kept reporting connected and never received anything again.

The service sends a keepalive line every 20 seconds, so a read that gets
nothing for 30 seconds now fails the stream: the error shows up in the
sync status and the client reconnects after retryDelayMs. WebSocket
connections already use the same timeout.

Closes powersync-ja#1208
@changeset-bot

changeset-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a373781

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@powersync/shared-internals Patch
@powersync/adapter-sql-js Patch
@powersync/capacitor Patch
@powersync/node Patch
@powersync/react-native Patch
@powersync/standalone-client Patch
@powersync/web Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP sync stream has no idle timeout, so a silently dead stream is never detected (Capacitor)

1 participant