mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:10:44 +00:00
refactor(gateway): rename startup sidecar deferral option
This commit is contained in:
@@ -583,7 +583,6 @@ describeLive("gateway live (ACP bind)", () => {
|
||||
bind: "loopback",
|
||||
auth: { mode: "token", token },
|
||||
controlUiEnabled: false,
|
||||
awaitStartupSidecars: true,
|
||||
});
|
||||
logLiveStep("gateway startup returned");
|
||||
await waitForGatewayPort({ host: "127.0.0.1", port, timeoutMs: CONNECT_TIMEOUT_MS });
|
||||
|
||||
@@ -365,7 +365,6 @@ describeLive("gateway live (native Codex conversation binding)", () => {
|
||||
bind: "loopback",
|
||||
auth: { mode: "token", token },
|
||||
controlUiEnabled: false,
|
||||
awaitStartupSidecars: true,
|
||||
});
|
||||
const client = await connectTestGatewayClient({
|
||||
url: `ws://127.0.0.1:${port}`,
|
||||
|
||||
@@ -183,6 +183,34 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("waits for sidecars by default before returning", async () => {
|
||||
let resumeSidecars!: () => void;
|
||||
const sidecarsReady = new Promise<{ pluginServices: null }>((resolve) => {
|
||||
resumeSidecars = () => resolve({ pluginServices: null });
|
||||
});
|
||||
const startGatewaySidecars = vi.fn(async () => {
|
||||
return await sidecarsReady;
|
||||
});
|
||||
let returned = false;
|
||||
|
||||
const runtimePromise = startGatewayPostAttachRuntime(
|
||||
createPostAttachParams(),
|
||||
createPostAttachRuntimeDeps({ startGatewaySidecars }),
|
||||
).then(() => {
|
||||
returned = true;
|
||||
});
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(startGatewaySidecars).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
await Promise.resolve();
|
||||
expect(returned).toBe(false);
|
||||
|
||||
resumeSidecars();
|
||||
await runtimePromise;
|
||||
expect(returned).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps startup-gated methods unavailable while sidecars are still resuming", async () => {
|
||||
let resumeSidecars!: () => void;
|
||||
const sidecarsReady = new Promise<{ pluginServices: null }>((resolve) => {
|
||||
@@ -197,7 +225,7 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
{
|
||||
...createPostAttachParams(),
|
||||
unavailableGatewayMethods,
|
||||
awaitSidecars: false,
|
||||
deferSidecars: true,
|
||||
},
|
||||
createPostAttachRuntimeDeps({ startGatewaySidecars }),
|
||||
);
|
||||
|
||||
@@ -420,7 +420,7 @@ export async function startGatewayPostAttachRuntime(
|
||||
onPluginServices?: (pluginServices: PluginServicesHandle | null) => void;
|
||||
onSidecarsReady?: () => void;
|
||||
startupTrace?: GatewayStartupTrace;
|
||||
awaitSidecars?: boolean;
|
||||
deferSidecars?: boolean;
|
||||
},
|
||||
runtimeDeps: GatewayPostAttachRuntimeDeps = defaultGatewayPostAttachRuntimeDeps,
|
||||
) {
|
||||
@@ -520,7 +520,7 @@ export async function startGatewayPostAttachRuntime(
|
||||
params.log.warn(`gateway sidecars failed to start: ${String(err)}`);
|
||||
});
|
||||
|
||||
if (params.awaitSidecars !== false) {
|
||||
if (params.deferSidecars !== true) {
|
||||
const [stopGatewayUpdateCheck, tailscaleCleanup, sidecarsResult] = await Promise.all([
|
||||
stopGatewayUpdateCheckPromise,
|
||||
tailscaleCleanupPromise,
|
||||
|
||||
@@ -230,11 +230,10 @@ export type GatewayServerOptions = {
|
||||
prompter: import("../wizard/prompts.js").WizardPrompter,
|
||||
) => Promise<void>;
|
||||
/**
|
||||
* Whether to wait for post-listen sidecars (channels, plugin services) to finish
|
||||
* starting before marking the gateway as ready. Defaults to true; pass false to
|
||||
* let sidecars start in the background.
|
||||
* Let post-listen sidecars (channels, plugin services) finish in the background.
|
||||
* Defaults to false so gateway startup waits until sidecars are ready.
|
||||
*/
|
||||
awaitStartupSidecars?: boolean;
|
||||
deferStartupSidecars?: boolean;
|
||||
/**
|
||||
* Optional startup timestamp used for concise readiness logging.
|
||||
*/
|
||||
@@ -844,7 +843,7 @@ export async function startGatewayServer(
|
||||
startupSidecarsReady = true;
|
||||
},
|
||||
startupTrace,
|
||||
awaitSidecars: opts.awaitStartupSidecars,
|
||||
deferSidecars: opts.deferStartupSidecars === true,
|
||||
}),
|
||||
));
|
||||
startupTrace.mark("ready");
|
||||
|
||||
Reference in New Issue
Block a user