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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Back off and retry the update banner navigation on ERR_NO_BUFFER_SPACE (#12081)
Daniel Hand27631e78cba
diff --git a/tests/studio/_playwright_robust.py b/tests/studio/_playwright_robust.pyindex 0845693fb56..21e53809b01 100644--- a/tests/studio/_playwright_robust.py+++ b/tests/studio/_playwright_robust.py@@ -494,6 +494,31 @@ BENIGN_CONSOLE_ERROR_PATTERNS: tuple[str, ...] = ()+# The OS can briefly run out of socket buffers on a busy runner (Windows and macOS lanes), and Chromium fails the+# navigation outright with net::ERR_NO_BUFFER_SPACE. It recovers on its own, so a navigation is retried after 5s,+# then 15s, as the chat, extra and model-config suites already do for their own requests. Any other error is raised+# at once: only this one says nothing about the app.+SOCKET_BUFFER_BACKOFF_S: tuple[float, ...] = (5.0, 15.0)+++def goto_with_socket_backoff(+ page: Any,+ url: str,+ *,+ sleep: Callable[[float], None] = time.sleep,+ **kwargs: Any,+) -> Any:+ for backoff_s in (*SOCKET_BUFFER_BACKOFF_S, None):+ try:+ return page.goto(url, **kwargs)+ except Exception as exc:+ if backoff_s is None or "ERR_NO_BUFFER_SPACE" not in str(exc):+ raise+ print(f"[goto] {url}: ERR_NO_BUFFER_SPACE; retrying in {backoff_s:.0f}s", flush = True)+ sleep(backoff_s)+ raise AssertionError("unreachable")++def wait_for_first(locator: Any, *, timeout_ms: int = 10_000) -> Any | None:"""The first match once it exists, or None once the wait expires.diff --git a/tests/studio/playwright_update_banner_layout.py b/tests/studio/playwright_update_banner_layout.pyindex 0ea21cf0c3c..874278233a3 100644--- a/tests/studio/playwright_update_banner_layout.py+++ b/tests/studio/playwright_update_banner_layout.py@@ -41,6 +41,7 @@ from playwright.sync_api import sync_playwrightsys.path.insert(0, str(Path(__file__).resolve().parent))from _playwright_robust import ( # noqa: E402chromium_launch_args,+ goto_with_socket_backoff,install_wall_clock_watchdog,report_failing_step,step_budget_s,@@ -923,7 +924,7 @@ def settle_cards(page, timeout_ms: int = SETTLED_MS) -> None:def boot(page, path: str) -> None:- page.goto(f"{BASE}{path}", wait_until = "domcontentloaded")+ goto_with_socket_backoff(page, f"{BASE}{path}", wait_until = "domcontentloaded")# Both cards are on a timer, so wait for them rather than for the worst case: this step runs 24 times and the job it# shares has minutes, not tens of minutes, to spare. The app card's 5s is shortened to E2E_DELAY_MS by the seed# script, llama.cpp keeps its 1s, and both still mount after first paint.diff --git a/tests/studio/test_goto_socket_backoff.py b/tests/studio/test_goto_socket_backoff.pynew file mode 100644index 00000000000..eb5853b6425--- /dev/null+++ b/tests/studio/test_goto_socket_backoff.py@@ -0,0 +1,66 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""goto_with_socket_backoff retries a navigation only on net::ERR_NO_BUFFER_SPACE.++The Windows UI lane failed the update banner suite on its first navigation with+`Page.goto: net::ERR_NO_BUFFER_SPACE`, the runner running out of socket buffers,+which says nothing about the app. Anything else still fails at once.+"""++from __future__ import annotations++import sys+from pathlib import Path++import pytest++sys.path.insert(0, str(Path(__file__).resolve().parent))++from _playwright_robust import SOCKET_BUFFER_BACKOFF_S, goto_with_socket_backoff # noqa: E402++ENOBUFS = "Page.goto: net::ERR_NO_BUFFER_SPACE at http://127.0.0.1:18897/"+++class _FakePage:+ def __init__(self, failures: list[str]) -> None:+ self._failures = list(failures)+ self.calls: list[tuple[str, dict]] = []++ def goto(self, url, **kwargs):+ self.calls.append((url, kwargs))+ if self._failures:+ raise RuntimeError(self._failures.pop(0))+ return "response"+++def test_a_socket_buffer_failure_is_retried_after_backing_off():+ page, slept = _FakePage([ENOBUFS, ENOBUFS]), []+ got = goto_with_socket_backoff(+ page, "http://x/", sleep = slept.append, wait_until = "domcontentloaded"+ )+ assert got == "response"+ assert slept == list(SOCKET_BUFFER_BACKOFF_S)+ assert page.calls == [("http://x/", {"wait_until": "domcontentloaded"})] * 3+++def test_the_retries_are_bounded():+ page, slept = _FakePage([ENOBUFS] * 5), []+ with pytest.raises(RuntimeError, match = "ERR_NO_BUFFER_SPACE"):+ goto_with_socket_backoff(page, "http://x/", sleep = slept.append)+ assert len(page.calls) == len(SOCKET_BUFFER_BACKOFF_S) + 1+++def test_any_other_navigation_error_is_raised_at_once():+ page, slept = _FakePage(["Page.goto: net::ERR_CONNECTION_REFUSED"]), []+ with pytest.raises(RuntimeError, match = "ERR_CONNECTION_REFUSED"):+ goto_with_socket_backoff(page, "http://x/", sleep = slept.append)+ assert slept == [] and len(page.calls) == 1+++def test_the_update_banner_suite_navigates_through_it():+ source = (Path(__file__).resolve().parent / "playwright_update_banner_layout.py").read_text(+ encoding = "utf-8"+ )+ assert 'goto_with_socket_backoff(page, f"{BASE}{path}"' in source+ assert "page.goto(" not in source