Skip to content

Studio smoke: report a transport failure instead of crashing on one - #10420

Merged
danielhanchen merged 1 commit into
mainfrom
fix/studio-smoke-flaky-waits
Sep 7, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/studio-smoke-flaky-waits

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Two fixed budgets in the Mac UI job that were themselves the problem, not the thing they were measuring. Neither is a product bug, and both failed unrelated PRs.

1. A socket timeout killed the whole smoke script

tests/studio/studio_api_smoke.py's http() caught only urllib.error.HTTPError, so a transport failure propagated out at module level:

Traceback (most recent call last):
  File ".../tests/studio/studio_api_smoke.py", line 447, in <module>
    code, body = http(
  File ".../tests/studio/studio_api_smoke.py", line 91, in http
    with urllib.request.urlopen(req, timeout = timeout) as r:
TimeoutError: timed out

The traceback names urlopen and a line number, and nothing about which endpoint was slow or for how long. Every section after it is abandoned.

Transport failures now return status 0, which the existing if code == 200 ... else fail(...) call sites already report as a failure, and http() emits the method, path, budget and exception so the reason sits next to the failure instead of only in the returned body:

  NET   POST /v1/embeddings failed after 90s -- TimeoutError: timed out

2. The /v1/embeddings ceiling had no margin

That call is the first in its section to force a model load, so it pays the load on top of the embedding. On a healthy macOS runner it takes 23.8s against a 30s ceiling, 79% of budget:

run /v1/models OK outcome elapsed
main dcf12378 00:36:46.83 OK /v1/embeddings -> 200 with data 00:37:10.64 23.8s
#10404 01:27:22.19 TimeoutError 01:27:52.20 30.0s (cap)
#10406 01:44:24.97 TimeoutError 01:44:55.02 30.0s (cap)
#10403 02:40:06.40 TimeoutError 02:40:36.42 30.0s (cap)

Three unrelated PRs (Windows code integrity, chat media turns, MLX install) off the same base a6e9880c, none touching the embeddings path, all pinned at exactly the cap. Raised to 90s. This is headroom rather than concealment: a genuinely slow endpoint still fails the check, and now reports rather than crashes.

3. A hard 3000ms wait after a hard navigation

tests/studio/playwright_loaded_models_indicator.py:

for route in ("/hub", "/train", "/images"):
    page.goto(BASE + route, wait_until = "domcontentloaded")
    page.wait_for_timeout(3000)
    check(f"card survives {route}", page.locator(CARD).count() > 0)

A full SPA reload plus a loaded-models poll, then a fixed 3000ms and a single non-retrying count(). It was the only fixed budget in the file not derived from SETTLE_MS (12000), and the sibling check one line above already uses wait_for_selector(CARD, timeout = 30_000). On #10409, whose diff is 19 lines of studio/backend/utils/mlx_repair.py and cannot reach the frontend:

[indicator] 35/38 checks passed
[indicator]   FAILED: card survives /hub
[indicator]   FAILED: card survives /train
[indicator]   FAILED: card survives /images

All three together, which is what a fixed budget looks like when the runner is loaded. The same job printed 38/38 on #10406, #10404 and #10403 at the identical base. Now waits for the card it is about to assert on, bounded by SETTLE_MS. The check() is unchanged and still fails if the card genuinely does not survive.

Verification

Against the pre-change http(), a refused connection and a socket timeout both raise URLError out of the function. After, both return 0 with the reason emitted and the run continuing:

  NET   POST /v1/embeddings failed after 5s -- URLError: <urlopen error [Errno 111] Connection refused>
returned code : 0 (falls to the else -> fail() branch)

Two fixed budgets in the Mac UI job that were the thing that was wrong, not
the thing they were measuring. Neither is a product bug; both failed unrelated
PRs.

studio_api_smoke.py caught only HTTPError, so a socket timeout propagated out
of http() and killed the script at module level. The traceback named urlopen
and a line number and nothing about which endpoint had been slow, and the
sections after it never ran. Transport failures now return status 0, which the
existing `if code == 200 ... else fail(...)` sites already report, and http()
emits the method, path, elapsed budget and exception so the reason is next to
the failure rather than only in the returned body.

The /v1/embeddings ceiling goes to 90s. This is the first request in that
section that forces a model load, so it pays the load on top of the embedding:
measured at 23.8s on a healthy runner against a 30s ceiling, 79% of budget.
Three unrelated PRs (Windows code integrity, chat media turns, MLX install)
timed out here at exactly 30.0s off the same base while main passed at 23.8s.
This is headroom, not concealment -- a genuinely slow endpoint still fails,
and now says so instead of crashing.

playwright_loaded_models_indicator.py waited a hard 3000ms after each hard
navigation before counting the card. Every other wait in the file derives from
SETTLE_MS (12000); the sibling check one line above already uses
wait_for_selector with a 30s timeout. Once the first route overran the budget
all three failed together, which is the signature. Waits for the card it is
about to assert on, bounded by SETTLE_MS. The check itself is unchanged and
still fails if the card really does not survive the navigation.

Verified against the pre-change code: a refused connection and a socket
timeout both raised URLError out of http() before, and both now return 0 with
the reason emitted and the run continuing.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-07T05:46:23.832299Z 8f383c2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f383c24d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# failed without saying that it timed out or after how long.
detail = f"{type(exc).__name__}: {exc}"
_emit(" NET ", f"{method} {path} failed after {timeout}s -- {detail}")
return 0, {"error": detail, "timeout": timeout}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record transport failures in PID probes

When either /api/inference/status request surrounding the force-reload encounters one of these caught transport errors, returning status 0 does not produce a failed assertion: _llama_pid() converts every non-200 result to None, and the caller then reports the force-reload check as OK with the PID comparison skipped. A transient timeout in either probe can therefore leave this smoke run with a successful exit code despite the logged NET failure; record the transport error as a failure here or make the PID probe propagate it to the caller.

Useful? React with 👍 / 👎.

return exc.code, json.loads(raw)
except (json.JSONDecodeError, UnicodeDecodeError):
return exc.code, raw
except (TimeoutError, ConnectionError, urllib.error.URLError) as exc:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch failures while reading HTTP error bodies

When an endpoint sends 4xx/5xx headers but stalls or disconnects while its response body is being read, exc.read() in the preceding HTTPError handler can raise TimeoutError; because that exception is raised from inside an except suite, Python does not route it through this sibling handler. The script therefore still terminates with a traceback for this transport-failure path instead of reporting and continuing as intended, so the HTTP-error body read also needs to be enclosed by the transport handler.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit fb9bb4e into main Sep 7, 2026
21 of 25 checks passed
@danielhanchen
danielhanchen deleted the fix/studio-smoke-flaky-waits branch September 7, 2026 06:48
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Sep 21, 2026
…age looked like (unslothai#10435)

* A failed presence check in the indicator driver should say what the page looked like

unslothai#10420 fixed the /hub, /train and /images loop: a hard 3000ms after each hard
navigation, the only fixed budget in the file not derived from SETTLE_MS, which
a contended macOS runner occasionally blew and then all three routes failed
together. Measured incidence of that flake before the fix was 1 in 1831 step
executions, the single occurrence being run 34070594239 attempt 1, which is 2.4
hours older than the fix. Two things it left behind.

The same shape is still here once, at the collapsed-pill reload. A reload has to
re-parse the bundle and re-read the stored preference before the pill can exist,
exactly as /hub must before the card can, and it is followed by a fixed
SETTLE_MS // 2 and a positive presence assertion with nothing in between. It has
not failed, but only because 6000ms is double the budget that did; the structure
is identical. It waits for the pill now. A scan for that specific shape across
all 31 playwright_*.py found no other instance that can fail a suite.

The other is that when a presence check does go the wrong way, all it prints is
"FAILED: card survives /hub", which is the one thing already known. It now
prints the states that separate the causes: pathname for a redirect or a route
that never resolved, root_children for an SPA that never mounted, auth_token for
a slip the /login guard in boot cannot catch mid-suite, show_pref for a
preference that was not seeded, status_reads for a poll that never fired, and
the console for a bundle that threw. Job logs here are kept about 26 hours, so a
failure that explains itself in the log is the difference between a diagnosis
and a rerun.

The wait keeps swallowing its exception -- the caller's assertion is what decides
pass or fail, and raising would turn a product verdict into a traceback that
loses the remaining checks -- but it no longer swallows it anonymously. A
TimeoutError means the card really was not there in the budget; a closed target
means the run died for a reason that has nothing to do with the card, and those
two were reported identically.

It also surfaces a third outcome the old pairing hid: wait_for_selector waits for
visible and count() counts attached, so a card that attaches and never becomes
visible times out and passes. That is latent today, since the component returns
null rather than rendering hidden, so this only logs a NOTE and changes no
verdict.

Not exercised end to end here: this box is Linux, so a playwright webkit install
is WebKitGTK rather than the WebKit the Mac job drives, and the driver also needs
a built frontend and a running studio. What did run: py_compile, the repo's 23
meta-tests over the playwright suites, the kwarg-spacing check, and a stub-page
unit test of the two new helpers covering the timeout, dead-browser, /login
redirect and collapsed-pill cases. The Mac job is the real check.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Report the status reads this page issued, not the total since boot

`Runtime.status_reads` counts every read since boot, so the raw total said
nothing about the page that just failed: a route whose poll never fired
still reported whatever boot and the earlier routes had accumulated, which
is the one cause this probe was added to expose.

Each navigation now takes the count before it and the report names the
reads that navigation issued, scoped the same way `console_errors` already
is. The total is kept alongside, since it is the thing to compare against
when the delta looks plausible.

Exercised directly, since the driver needs a built frontend and a running
studio: a page issuing no reads with 7 behind it reported `status_reads=7`
before this and reports `0 (of 7 since boot)` now, against `3 (of 10 since
boot)` when the poll did fire.

* Let a page that cannot be asked still reach its own diagnostic

Naming what ended a wait is pointless if the next line re-raises it. A
closed target or a navigation error fails `await_selector`, which records
the name, and then fails `locator.count()` the same way, so the caller never
reached its `check()` and the detail it had just collected was replaced by
the traceback this change exists to avoid. Both presence checks did this.

`counted` returns None when the page cannot be asked, and None is not zero:
zero is a page that answered and had no card, None is a page that could not
answer, and only the first is a verdict about the card. The probe block
reports `<unreadable>` for the same reason, rather than a number standing in
for an answer it never got.

Exercised against a page that raises on every call: the old line raised and
printed nothing, and the check now runs and reports
`wait=Closed: Target page, context or browser has been closed`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…age looked like (unslothai#10435)

* A failed presence check in the indicator driver should say what the page looked like

unslothai#10420 fixed the /hub, /train and /images loop: a hard 3000ms after each hard
navigation, the only fixed budget in the file not derived from SETTLE_MS, which
a contended macOS runner occasionally blew and then all three routes failed
together. Measured incidence of that flake before the fix was 1 in 1831 step
executions, the single occurrence being run 34070594239 attempt 1, which is 2.4
hours older than the fix. Two things it left behind.

The same shape is still here once, at the collapsed-pill reload. A reload has to
re-parse the bundle and re-read the stored preference before the pill can exist,
exactly as /hub must before the card can, and it is followed by a fixed
SETTLE_MS // 2 and a positive presence assertion with nothing in between. It has
not failed, but only because 6000ms is double the budget that did; the structure
is identical. It waits for the pill now. A scan for that specific shape across
all 31 playwright_*.py found no other instance that can fail a suite.

The other is that when a presence check does go the wrong way, all it prints is
"FAILED: card survives /hub", which is the one thing already known. It now
prints the states that separate the causes: pathname for a redirect or a route
that never resolved, root_children for an SPA that never mounted, auth_token for
a slip the /login guard in boot cannot catch mid-suite, show_pref for a
preference that was not seeded, status_reads for a poll that never fired, and
the console for a bundle that threw. Job logs here are kept about 26 hours, so a
failure that explains itself in the log is the difference between a diagnosis
and a rerun.

The wait keeps swallowing its exception -- the caller's assertion is what decides
pass or fail, and raising would turn a product verdict into a traceback that
loses the remaining checks -- but it no longer swallows it anonymously. A
TimeoutError means the card really was not there in the budget; a closed target
means the run died for a reason that has nothing to do with the card, and those
two were reported identically.

It also surfaces a third outcome the old pairing hid: wait_for_selector waits for
visible and count() counts attached, so a card that attaches and never becomes
visible times out and passes. That is latent today, since the component returns
null rather than rendering hidden, so this only logs a NOTE and changes no
verdict.

Not exercised end to end here: this box is Linux, so a playwright webkit install
is WebKitGTK rather than the WebKit the Mac job drives, and the driver also needs
a built frontend and a running studio. What did run: py_compile, the repo's 23
meta-tests over the playwright suites, the kwarg-spacing check, and a stub-page
unit test of the two new helpers covering the timeout, dead-browser, /login
redirect and collapsed-pill cases. The Mac job is the real check.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Report the status reads this page issued, not the total since boot

`Runtime.status_reads` counts every read since boot, so the raw total said
nothing about the page that just failed: a route whose poll never fired
still reported whatever boot and the earlier routes had accumulated, which
is the one cause this probe was added to expose.

Each navigation now takes the count before it and the report names the
reads that navigation issued, scoped the same way `console_errors` already
is. The total is kept alongside, since it is the thing to compare against
when the delta looks plausible.

Exercised directly, since the driver needs a built frontend and a running
studio: a page issuing no reads with 7 behind it reported `status_reads=7`
before this and reports `0 (of 7 since boot)` now, against `3 (of 10 since
boot)` when the poll did fire.

* Let a page that cannot be asked still reach its own diagnostic

Naming what ended a wait is pointless if the next line re-raises it. A
closed target or a navigation error fails `await_selector`, which records
the name, and then fails `locator.count()` the same way, so the caller never
reached its `check()` and the detail it had just collected was replaced by
the traceback this change exists to avoid. Both presence checks did this.

`counted` returns None when the page cannot be asked, and None is not zero:
zero is a page that answered and had no card, None is a page that could not
answer, and only the first is a verdict about the card. The probe block
reports `<unreadable>` for the same reason, rather than a number standing in
for an answer it never got.

Exercised against a page that raises on every call: the old line raised and
printed nothing, and the check now runs and reports
`wait=Closed: Target page, context or browser has been closed`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant