From 2b3eb8b6ca639b1bcacdd993e9f041c6177ca247 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 21 Oct 2026 12:25:53 +0800 Subject: [PATCH] fix(ci): poll for upstream socket destroy in the abort x proxy-json case Fixed 300ms sleep races the abort propagation on slow runners (win/node24 rerun of #4095 flaked here); poll up to 3s for socketsClosed()>=1 before asserting. --- tests/wire-exit-matrix.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/wire-exit-matrix.test.ts b/tests/wire-exit-matrix.test.ts index 23ef500277..18435cf078 100644 --- a/tests/wire-exit-matrix.test.ts +++ b/tests/wire-exit-matrix.test.ts @@ -273,7 +273,11 @@ test("abort x proxy-json: client abort while the JSON is buffering destroys the try { const url = `http://127.0.0.1:${proxyPort}/bili/http://127.0.0.1:${up.port}/v1/chat/completions`; await abortAfterFirstByte(url, { "content-type": "application/json", "x-acp-session": "mx-abort-json" }, JSON.stringify({ model: "m-test", max_tokens: 1024, messages: [{ role: "user", content: "hi" }] })); - await new Promise((r) => setTimeout(r, 300)); + // Poll for the abort to propagate instead of a fixed 300ms sleep: + // slow runners (win/node24) destroy the upstream socket later. + for (let i = 0; i < 30 && up.socketsClosed() < 1; i += 1) { + await new Promise((r) => setTimeout(r, 100)); + } assert.ok(up.socketsClosed() >= 1, `upstream socket(s) destroyed after client abort (closed=${up.socketsClosed()})`); } finally { proxy.close();