From 2972c95649f51aad826e93e2a4def7dc92b8acb9 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 8 Apr 2026 11:52:06 -0700 Subject: [PATCH 1/3] Fix WebSocket test double-done flake When the WebSocket connection fails, onerror fires followed by onclose. Both called done(), causing mocha's 'done() called multiple times' error. Guard done() with a finished flag so only the first callback completes the test. This fixes the intermittent CI flake on Win32_x64_JSI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Tests/UnitTests/Scripts/tests.ts | 41 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/Tests/UnitTests/Scripts/tests.ts b/Tests/UnitTests/Scripts/tests.ts index a79ebdf0..6c99606e 100644 --- a/Tests/UnitTests/Scripts/tests.ts +++ b/Tests/UnitTests/Scripts/tests.ts @@ -408,6 +408,14 @@ if (hostPlatform !== "Unix") { it("should connect correctly with one websocket connection", function (done) { const ws = new WebSocket("wss://ws.postman-echo.com/raw"); const testMessage = "testMessage"; + let finished = false; + const finish = (err?: Error) => { + if (!finished) { + finished = true; + done(err); + } + }; + ws.onopen = () => { try { expect(ws).to.have.property("readyState", 1); @@ -415,7 +423,7 @@ if (hostPlatform !== "Unix") { ws.send(testMessage); } catch (e) { - done(e); + finish(e as Error); } }; @@ -425,28 +433,35 @@ if (hostPlatform !== "Unix") { ws.close(); } catch (e) { - done(e); + finish(e as Error); } }; ws.onclose = () => { try { expect(ws).to.have.property("readyState", 3); - done(); + finish(); } catch (e) { - done(e); + finish(e as Error); } }; ws.onerror = (ev) => { - done(new Error("WebSocket failed")); + finish(new Error("WebSocket failed")); }; }); it("should connect correctly with multiple websocket connections", function (done) { const testMessage1 = "testMessage1"; const testMessage2 = "testMessage2"; + let finished = false; + const finish = (err?: Error) => { + if (!finished) { + finished = true; + done(err); + } + }; const ws1 = new WebSocket("wss://ws.postman-echo.com/raw"); ws1.onopen = () => { @@ -458,7 +473,7 @@ if (hostPlatform !== "Unix") { ws2.send(testMessage2); } catch (e) { - done(e); + finish(e as Error); } }; @@ -468,7 +483,7 @@ if (hostPlatform !== "Unix") { ws2.close(); } catch (e) { - done(e); + finish(e as Error); } }; @@ -478,12 +493,12 @@ if (hostPlatform !== "Unix") { ws1.send(testMessage1); } catch (e) { - done(e); + finish(e as Error); } }; ws2.onerror = (ev) => { - done(new Error("Websocket failed")); + finish(new Error("Websocket failed")); }; } @@ -493,22 +508,22 @@ if (hostPlatform !== "Unix") { ws1.close(); } catch (e) { - done(e); + finish(e as Error); } } ws1.onclose = () => { try { expect(ws1).to.have.property("readyState", 3); - done(); + finish(); } catch (e) { - done(e); + finish(e as Error); } } ws1.onerror = (ev) => { - done(new Error("Websocket failed")); + finish(new Error("Websocket failed")); }; }); From 0310406b535275aad0f2db2a3a042555374f266b Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 9 Apr 2026 08:10:16 -0700 Subject: [PATCH 2/3] Fix inconsistent WebSocket capitalization in error messages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Tests/UnitTests/Scripts/tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/UnitTests/Scripts/tests.ts b/Tests/UnitTests/Scripts/tests.ts index 6c99606e..b64d70f5 100644 --- a/Tests/UnitTests/Scripts/tests.ts +++ b/Tests/UnitTests/Scripts/tests.ts @@ -498,7 +498,7 @@ if (hostPlatform !== "Unix") { }; ws2.onerror = (ev) => { - finish(new Error("Websocket failed")); + finish(new Error("WebSocket failed")); }; } @@ -523,7 +523,7 @@ if (hostPlatform !== "Unix") { } ws1.onerror = (ev) => { - finish(new Error("Websocket failed")); + finish(new Error("WebSocket failed")); }; }); From a516b5dd161409585efca0ef1188ad8406abb85d Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 9 Apr 2026 17:18:51 -0700 Subject: [PATCH 3/3] Retrigger CI