From 2f162e2c4fb67bc0a5925ef6163e44b5d58b4dea Mon Sep 17 00:00:00 2001 From: pnwmatt <180812017+pnwmatt@users.noreply.github.com> Date: Sun, 19 Oct 2025 14:36:18 -0700 Subject: [PATCH 1/2] subscribe pingpong --- client/remote/client.go | 25 ++++++++++++++++++++----- client/sync/coordinator.go | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/remote/client.go b/client/remote/client.go index c1ee4a6..4e1d997 100644 --- a/client/remote/client.go +++ b/client/remote/client.go @@ -1455,14 +1455,29 @@ func (c *Client) writeLoop() { err := conn.WriteMessage(websocket.BinaryMessage, data) if err != nil { c.logger.Error("WebSocket write error", zap.Error(err)) + + // If the error indicates we already sent a close, treat this as a normal + // closure for PUSH syncs and mark the sync completed so the caller can + // finish processing. This happens when the websocket library returns + // "websocket: close sent" while attempting to write after a close. + if strings.Contains(err.Error(), "close sent") { + c.logger.Info("Write error contains 'close sent' - treating as normal closure") + c.logger.Info("Ending PUSH sync due to close-sent write error") + c.setSyncCompleted(true) + } c.setError(err) c.setConnected(false) - // Signal potential reconnection - select { - case c.reconnectChan <- struct{}{}: - default: - } + // Treat this as a true disconnection (do not trigger reconnect). + // Close the read queue so any readers observe EOF and stop. + func() { + defer func() { + if r := recover(); r != nil { + // ignore if already closed + } + }() + close(c.readQueue) + }() return } diff --git a/client/sync/coordinator.go b/client/sync/coordinator.go index 4c40637..6151280 100644 --- a/client/sync/coordinator.go +++ b/client/sync/coordinator.go @@ -361,7 +361,7 @@ func (c *Coordinator) executePull(isSubscription bool) error { AuthKey: authResult.AccessKey, ReplicaID: authResult.ReplicaID, Timeout: 8000, - PingPong: false, // No ping/pong needed for single sync + PingPong: true, // Ping/pong enabled for subscription sync Logger: c.logger.Named("remote"), Subscribe: false, // Subscription handled separately EnableTrafficInspection: c.config.Verbose, From 285cfbe80c36abcc9f07a4e881d17e453c3f5c5f Mon Sep 17 00:00:00 2001 From: pnwmatt <180812017+pnwmatt@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:46:57 -0800 Subject: [PATCH 2/2] bump to v0.0.9 --- client/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/main.go b/client/main.go index 6c71614..d5bbb2e 100644 --- a/client/main.go +++ b/client/main.go @@ -15,7 +15,7 @@ import ( "github.com/sqlrsync/sqlrsync.com/sync" ) -var VERSION = "0.0.8" +var VERSION = "0.0.9" var ( serverURL string verbose bool