refactor(gateway): rename startup sidecar deferral option · openclaw/openclaw@f07b00d
steipete
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -583,7 +583,6 @@ describeLive("gateway live (ACP bind)", () => {
|
583 | 583 | bind: "loopback", |
584 | 584 | auth: { mode: "token", token }, |
585 | 585 | controlUiEnabled: false, |
586 | | -awaitStartupSidecars: true, |
587 | 586 | }); |
588 | 587 | logLiveStep("gateway startup returned"); |
589 | 588 | await waitForGatewayPort({ host: "127.0.0.1", port, timeoutMs: CONNECT_TIMEOUT_MS }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -365,7 +365,6 @@ describeLive("gateway live (native Codex conversation binding)", () => {
|
365 | 365 | bind: "loopback", |
366 | 366 | auth: { mode: "token", token }, |
367 | 367 | controlUiEnabled: false, |
368 | | -awaitStartupSidecars: true, |
369 | 368 | }); |
370 | 369 | const client = await connectTestGatewayClient({ |
371 | 370 | url: `ws://127.0.0.1:${port}`, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -183,6 +183,34 @@ describe("startGatewayPostAttachRuntime", () => {
|
183 | 183 | }); |
184 | 184 | }); |
185 | 185 | |
| 186 | +it("waits for sidecars by default before returning", async () => { |
| 187 | +let resumeSidecars!: () => void; |
| 188 | +const sidecarsReady = new Promise<{ pluginServices: null }>((resolve) => { |
| 189 | +resumeSidecars = () => resolve({ pluginServices: null }); |
| 190 | +}); |
| 191 | +const startGatewaySidecars = vi.fn(async () => { |
| 192 | +return await sidecarsReady; |
| 193 | +}); |
| 194 | +let returned = false; |
| 195 | + |
| 196 | +const runtimePromise = startGatewayPostAttachRuntime( |
| 197 | +createPostAttachParams(), |
| 198 | +createPostAttachRuntimeDeps({ startGatewaySidecars }), |
| 199 | +).then(() => { |
| 200 | +returned = true; |
| 201 | +}); |
| 202 | + |
| 203 | +await vi.waitFor(() => { |
| 204 | +expect(startGatewaySidecars).toHaveBeenCalledTimes(1); |
| 205 | +}); |
| 206 | +await Promise.resolve(); |
| 207 | +expect(returned).toBe(false); |
| 208 | + |
| 209 | +resumeSidecars(); |
| 210 | +await runtimePromise; |
| 211 | +expect(returned).toBe(true); |
| 212 | +}); |
| 213 | + |
186 | 214 | it("keeps startup-gated methods unavailable while sidecars are still resuming", async () => { |
187 | 215 | let resumeSidecars!: () => void; |
188 | 216 | const sidecarsReady = new Promise<{ pluginServices: null }>((resolve) => { |
@@ -197,7 +225,7 @@ describe("startGatewayPostAttachRuntime", () => {
|
197 | 225 | { |
198 | 226 | ...createPostAttachParams(), |
199 | 227 | unavailableGatewayMethods, |
200 | | -awaitSidecars: false, |
| 228 | +deferSidecars: true, |
201 | 229 | }, |
202 | 230 | createPostAttachRuntimeDeps({ startGatewaySidecars }), |
203 | 231 | ); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -420,7 +420,7 @@ export async function startGatewayPostAttachRuntime(
|
420 | 420 | onPluginServices?: (pluginServices: PluginServicesHandle | null) => void; |
421 | 421 | onSidecarsReady?: () => void; |
422 | 422 | startupTrace?: GatewayStartupTrace; |
423 | | -awaitSidecars?: boolean; |
| 423 | +deferSidecars?: boolean; |
424 | 424 | }, |
425 | 425 | runtimeDeps: GatewayPostAttachRuntimeDeps = defaultGatewayPostAttachRuntimeDeps, |
426 | 426 | ) { |
@@ -520,7 +520,7 @@ export async function startGatewayPostAttachRuntime(
|
520 | 520 | params.log.warn(`gateway sidecars failed to start: ${String(err)}`); |
521 | 521 | }); |
522 | 522 | |
523 | | -if (params.awaitSidecars !== false) { |
| 523 | +if (params.deferSidecars !== true) { |
524 | 524 | const [stopGatewayUpdateCheck, tailscaleCleanup, sidecarsResult] = await Promise.all([ |
525 | 525 | stopGatewayUpdateCheckPromise, |
526 | 526 | tailscaleCleanupPromise, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -230,11 +230,10 @@ export type GatewayServerOptions = {
|
230 | 230 | prompter: import("../wizard/prompts.js").WizardPrompter, |
231 | 231 | ) => Promise<void>; |
232 | 232 | /** |
233 | | - * Whether to wait for post-listen sidecars (channels, plugin services) to finish |
234 | | - * starting before marking the gateway as ready. Defaults to true; pass false to |
235 | | - * let sidecars start in the background. |
| 233 | + * Let post-listen sidecars (channels, plugin services) finish in the background. |
| 234 | + * Defaults to false so gateway startup waits until sidecars are ready. |
236 | 235 | */ |
237 | | -awaitStartupSidecars?: boolean; |
| 236 | +deferStartupSidecars?: boolean; |
238 | 237 | /** |
239 | 238 | * Optional startup timestamp used for concise readiness logging. |
240 | 239 | */ |
@@ -844,7 +843,7 @@ export async function startGatewayServer(
|
844 | 843 | startupSidecarsReady = true; |
845 | 844 | }, |
846 | 845 | startupTrace, |
847 | | -awaitSidecars: opts.awaitStartupSidecars, |
| 846 | +deferSidecars: opts.deferStartupSidecars === true, |
848 | 847 | }), |
849 | 848 | )); |
850 | 849 | startupTrace.mark("ready"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。