






















@@ -886,6 +886,65 @@ describe("startGatewayPostAttachRuntime", () => {
886886);
887887});
888888889+it("returns plugin services already reported by deferred sidecars", async () => {
890+await withEnvAsync(
891+{ OPENCLAW_SKIP_CHANNELS: undefined, OPENCLAW_SKIP_PROVIDERS: undefined },
892+async () => {
893+let releaseStartupLog: (() => void) | undefined;
894+let releaseChannels: (() => void) | undefined;
895+const pluginServices = { stop: vi.fn(async () => {}) } as never;
896+const onPluginServices = vi.fn();
897+const onSidecarsReady = vi.fn();
898+const logGatewayStartup = vi.fn(
899+() =>
900+new Promise<void>((resolve) => {
901+releaseStartupLog = resolve;
902+}),
903+);
904+const startChannels = vi.fn(
905+() =>
906+new Promise<void>((resolve) => {
907+releaseChannels = resolve;
908+}),
909+);
910+hoisted.startPluginServices.mockResolvedValueOnce(pluginServices);
911+912+const runtimePromise = startGatewayPostAttachRuntime(
913+{
914+ ...createPostAttachParams({
915+deferSidecars: true,
916+ onPluginServices,
917+ onSidecarsReady,
918+}),
919+ startChannels,
920+},
921+createPostAttachRuntimeDeps({
922+ logGatewayStartup,
923+ startGatewaySidecars,
924+}),
925+);
926+927+await vi.waitFor(() => {
928+expect(onPluginServices).toHaveBeenCalledWith(pluginServices);
929+});
930+931+if (!releaseStartupLog) {
932+throw new Error("Expected startup log release callback to be initialized");
933+}
934+releaseStartupLog();
935+await expect(runtimePromise).resolves.toMatchObject({ pluginServices });
936+937+if (!releaseChannels) {
938+throw new Error("Expected channel startup release callback to be initialized");
939+}
940+releaseChannels();
941+await vi.waitFor(() => {
942+expect(onSidecarsReady).toHaveBeenCalledTimes(1);
943+});
944+},
945+);
946+});
947+889948it("emits a startup trace span when channel startup is skipped", async () => {
890949const trace = createStartupTraceRecorder();
891950const logChannels = { info: vi.fn(), error: vi.fn() };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。