fix: resolve Windows gateway reconnect race condition and translate comments (#787)

This commit is contained in:
paisley
2026-04-07 16:58:18 +08:00
committed by GitHub
Unverified
parent d8750e135b
commit c3a735a49c
5 changed files with 97 additions and 17 deletions

View File

@@ -162,7 +162,12 @@ export async function launchGatewayProcess(options: {
});
child.on('exit', (code: number) => {
const expectedExit = !options.getShouldReconnect() || options.getCurrentState() === 'stopped';
// Only check shouldReconnect — not current state. On Windows the WS
// close handler fires before the process exit handler and sets state to
// 'stopped', which would make an unexpected crash look like a planned
// shutdown in logs. shouldReconnect is the reliable indicator: stop()
// sets it to false (expected), crashes leave it true (unexpected).
const expectedExit = !options.getShouldReconnect();
const level = expectedExit ? logger.info : logger.warn;
level(`Gateway process exited (code=${code}, expected=${expectedExit ? 'yes' : 'no'})`);
options.onExit(child, code);