fix: connection resilience, sync-on-save — fixes #287, #299, #309, #323#374
Open
iamhyc wants to merge 2 commits into
Open
fix: connection resilience, sync-on-save — fixes #287, #299, #309, #323#374iamhyc wants to merge 2 commits into
iamhyc wants to merge 2 commits into
Conversation
added 2 commits
May 8, 2026 21:25
…onnection lost (fixes #309) Root cause: socket.io init() created new TCP connections without disconnecting old ones, causing orphaned connections. The OS TCP stack responded with RST when the server sent late/out-of-order data on abandoned connections, which could cause the server to drop ALL connections from this client. Changes by file: - src/api/base.ts: - Enable socket.io auto-reconnect (reconnect: true, delay 1s-16s, 10 attempts) instead of manual socket recreation on every transient hiccup - Add HTTP request retry (up to 2x) for transient errors (5xx, ECONNRESET, ETIMEDOUT, ECONNREFUSED, ENOTFOUND) - src/api/socketio.ts: - Properly disconnect old socket (removeAllListeners + disconnect) before creating new one to send FIN instead of RST - Disable auto-reconnect on connectionRejected to prevent futile reconnect->reject->reconnect loops - Fix EventBus listener leak (MaxListenersExceededWarning) by tracking Disposables and cleaning up before reinit - Add v2->v1 fallback when both schemes rejected - Replace unsafe throw with console.error on socket error events - Track _socketInitScheme; expose needsReinit getter - src/core/remoteFileSystemProvider.ts: - Exponential backoff: 3->5 retries, 0s->1s/2s/4s/8s/16s delays - Only recreate socket on scheme change (needsReinit), not on every retry; let socket.io auto-reconnect handle transient disconnects - 2s disconnect debounce to ignore rapid connect/disconnect cycles - 1s delay before initiating reconnection after disconnect - Show 'Reconnecting to {server}...' progress notification during retries instead of silent failures - Add 'Retry' button alongside 'Reload' in error dialog - Reset retry state on connectionAccepted - src/collaboration/clientManager.ts: - 15s grace period before clearing collaborator decorations on disconnect; show 'Reconnecting...' spin indicator instead - Only show red 'Not connected' after grace period expires - l10n/bundle.l10n.json: - Add localization strings: Retry, Reconnecting..., Reconnecting to {serverName}..., Connection interrupted...
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.
Summary
Two fixes on the
connection-enhancebranch that address four long-standing issues with connection stability and local-replica sync behavior.Commit 1: Connection resilience (
3610590)Fixes: #309, #287
Root cause:
socket.io init()created new TCP connections without properly disconnecting old ones, leaving orphaned connections. When the server sent late data on abandoned connections, the OS TCP stack responded with RST, which could cause the server to drop all connections from this client. After sleep/lock, connections were silently broken while the UI showed "connected."Changes:
src/api/base.tssrc/api/socketio.tsdisconnect()old socket (FIN not RST); fix EventBus listener leak; v2→v1 fallbacksrc/core/remoteFileSystemProvider.tssrc/collaboration/clientManager.tsCommit 2: Sync on explicit save (
f2e3f63)Fixes: #323, #299
Root cause: The local file system watcher (
localWatcher.onDidChange) fired for all file modifications — including git operations (checkout, revert, discard) and LaTeX compilation outputs. This pushed unintended changes to Overleaf, causing data loss (#323) and zeroed-out PDFs (#299).Change: Replaced
localWatcher.onDidChangewithvscode.workspace.onDidSaveTextDocument. Now only explicit user saves in the editor trigger a push to Overleaf. File creation/deletion watchers and pull-direction (Overleaf→local) sync are unchanged.Issues Closed