fix(gateway): wait for event loop before client start

This commit is contained in:
Peter Steinberger
2026-04-29 14:50:21 +01:00
parent a972c9ec45
commit 6bbacd14a3
24 changed files with 675 additions and 68 deletions

View File

@@ -1,4 +1,5 @@
import { getRuntimeConfig, type OpenClawConfig } from "../config/config.js";
import { startGatewayClientWhenEventLoopReady } from "../gateway/client-start-readiness.js";
import { GatewayClient, type GatewayReconnectPausedInfo } from "../gateway/client.js";
import { resolveGatewayConnectionAuth } from "../gateway/connection-auth.js";
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js";
@@ -269,6 +270,11 @@ export async function runNodeHost(opts: NodeHostRunOptions): Promise<void> {
return bins;
}, pathEnv);
client.start();
const readiness = await startGatewayClientWhenEventLoopReady(client, {
clientOptions: { preauthHandshakeTimeoutMs: cfg.gateway?.handshakeTimeoutMs },
});
if (!readiness.ready) {
throw new Error("node host gateway event loop readiness timeout");
}
await new Promise(() => {});
}