fix(codex): scope stale shared-client cleanup · openclaw/openclaw@15f285c
Lucenx9
·
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -144,4 +144,47 @@ describe("shared Codex app-server client", () => {
|
144 | 144 | expect(startSpy).toHaveBeenCalledTimes(2); |
145 | 145 | expect(first.process.kill).toHaveBeenCalledWith("SIGTERM"); |
146 | 146 | }); |
| 147 | + |
| 148 | +it("does not let a superseded shared-client failure tear down the newer client", async () => { |
| 149 | +const first = createClientHarness(); |
| 150 | +const second = createClientHarness(); |
| 151 | +vi.spyOn(CodexAppServerClient, "start") |
| 152 | +.mockReturnValueOnce(first.client) |
| 153 | +.mockReturnValueOnce(second.client); |
| 154 | + |
| 155 | +const firstList = listCodexAppServerModels({ |
| 156 | +timeoutMs: 1000, |
| 157 | +startOptions: { |
| 158 | +transport: "websocket", |
| 159 | +command: "codex", |
| 160 | +args: [], |
| 161 | +url: "ws://127.0.0.1:39175", |
| 162 | +authToken: "tok-first", |
| 163 | +headers: {}, |
| 164 | +}, |
| 165 | +}); |
| 166 | +const firstFailure = firstList.catch((error: unknown) => error); |
| 167 | +await vi.waitFor(() => expect(first.writes.length).toBeGreaterThanOrEqual(1)); |
| 168 | + |
| 169 | +const secondList = listCodexAppServerModels({ |
| 170 | +timeoutMs: 1000, |
| 171 | +startOptions: { |
| 172 | +transport: "websocket", |
| 173 | +command: "codex", |
| 174 | +args: [], |
| 175 | +url: "ws://127.0.0.1:39175", |
| 176 | +authToken: "tok-second", |
| 177 | +headers: {}, |
| 178 | +}, |
| 179 | +}); |
| 180 | +await vi.waitFor(() => expect(second.writes.length).toBeGreaterThanOrEqual(1)); |
| 181 | + |
| 182 | +await expect(firstFailure).resolves.toBeInstanceOf(Error); |
| 183 | + |
| 184 | +await sendInitializeResult(second, "openclaw/0.118.0 (macOS; test)"); |
| 185 | +await sendEmptyModelList(second); |
| 186 | +await expect(secondList).resolves.toEqual({ models: [] }); |
| 187 | + |
| 188 | +expect(second.process.kill).not.toHaveBeenCalled(); |
| 189 | +}); |
147 | 190 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。