Skip to content

Commit eb948d5

Browse files
authored
fix(gateway): restore WebSocket heartbeat ping on Windows (#722)
1 parent ec8db0b commit eb948d5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

electron/gateway/manager.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,7 @@ export class GatewayManager extends EventEmitter {
787787
port,
788788
connectedAt: Date.now(),
789789
});
790-
// On Windows, skip WebSocket heartbeat ping to avoid cascading failures:
791-
// heartbeat timeout → terminate socket → reconnect → port conflict
792-
// (old process holds port due to TCP TIME_WAIT) → ~2 min downtime.
793-
// Gateway is a local child process; actual crashes are caught by the
794-
// process exit handler, and graceful restarts use code=1012 close frames.
795-
if (process.platform !== 'win32') {
796-
this.startPing();
797-
}
790+
this.startPing();
798791
},
799792
onMessage: (message) => {
800793
this.handleMessage(message);
@@ -900,6 +893,14 @@ export class GatewayManager extends EventEmitter {
900893
} catch (error) {
901894
logger.warn('Failed to terminate stale Gateway socket after heartbeat timeout:', error);
902895
}
896+
897+
// On Windows, onCloseAfterHandshake intentionally skips scheduleReconnect()
898+
// to avoid double-reconnect races with the process exit handler. However,
899+
// a heartbeat timeout means the socket is stale while the process may still
900+
// be alive (no exit event), so we must explicitly trigger reconnect here.
901+
if (process.platform === 'win32') {
902+
this.scheduleReconnect();
903+
}
903904
},
904905
});
905906
}

0 commit comments

Comments
 (0)