File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments