Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Tauri transport test: start the late backend after the old ladder is spent, not at 3s (#12930)

Daniel Han03cdc5c33970
diff --git a/studio/frontend/tests/tauri-backend-transport-failure.test.ts b/studio/frontend/tests/tauri-backend-transport-failure.test.ts
index 1f5b8b3fa37..192432e09ba 100644
--- a/studio/frontend/tests/tauri-backend-transport-failure.test.ts
+++ b/studio/frontend/tests/tauri-backend-transport-failure.test.ts
@@ -91,7 +91,7 @@ function listenAfter(server: Server, port: number, delayMs: number): void {
}, delayMs).unref();
}
-// The host below starts accepting at 3s: inside the new ladder, outside the old 250 + 750 + 1500ms one.
+// The old ladder was 250 + 750 + 1500ms: 4 attempts. The unowned-port case below starts its host at 3s.
const SLOW_LOOPBACK_ACCEPT_DELAY_MS = 3_000;
const OLD_LADDER_ATTEMPTS = 4;
@@ -103,14 +103,22 @@ test("a backend that accepts late is reached instead of declared not running", a
});
const originalFetch = globalThis.fetch;
let attempts = 0;
+ // Start accepting once the old ladder's last attempt has been refused, not at a fixed
+ // time: a refused loopback connect takes about a second on Windows, so a timer at 3s
+ // let attempt 4 succeed there and the count could not tell the two ladders apart.
globalThis.fetch = async (input, init) => {
attempts += 1;
- return await originalFetch(input, init);
+ try {
+ return await originalFetch(input, init);
+ } finally {
+ if (attempts === OLD_LADDER_ATTEMPTS && !server.listening) {
+ await new Promise<void>((resolve) => server.listen(port, "127.0.0.1", resolve));
+ }
+ }
};
try {
- listenAfter(server, port, SLOW_LOOPBACK_ACCEPT_DELAY_MS);
- // The connects here are genuinely refused until 3s. `check_backend_is_gone` answers
+ // The connects here are genuinely refused until the old ladder is spent. `check_backend_is_gone` answers
// false anyway, because a backend this app is bringing up owns the port before it binds
// it -- which is why the fast path asks for absence rather than for presence.
const authApi = loadAuthApi({ port, checkGone: () => false });