Skip to content

A failed presence check in the indicator driver should say what the page looked like - #10435

Merged
danielhanchen merged 4 commits into
mainfrom
fix/indicator-presence-check-diagnostics
Sep 21, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/indicator-presence-check-diagnostics

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #10420, which fixed the /hub, /train, /images loop. Two things it left behind.

What the flake actually was

Measured across every Loaded-models indicator (WebKit) step execution from 2026-08-25 to 2026-09-07: 1 failure in 1,831 (0.055%). The single occurrence is run 34070594239 attempt 1 (job 101587088024, PR #10409, head 83a5db2cf), which printed 35/38 with all three routes failing together. Attempt 2 hid it from gh run list, which made it look more frequent than it was. git merge-base --is-ancestor fb9bb4ea0 83a5db2cf is false, and the step ran 04:08-04:26Z, about 2.4 hours before #10420 landed.

Worth recording since it shaped the method: job logs in this repo are retained about 24-26 hours and return 410 Gone above that, so the full-window figure comes from step exit statuses (valid because run-studio-indicator-browser.sh is set -euo pipefail ending on the driver, with no continue-on-error), and the log-level check covers only the ~28h that survives. That retention is also the argument for the second half of this PR.

The same shape is still here once

tests/studio/playwright_loaded_models_indicator.py:572-574 on main:

page.reload(wait_until = "domcontentloaded")
page.wait_for_timeout(SETTLE_MS // 2)
check("the collapsed state survives a reload", page.locator(pill).count() > 0)

Hard navigation, fixed budget, positive presence assertion, nothing in between. A reload has to re-parse the bundle and re-read unsloth_loaded_models_collapsed before the pill can exist, exactly as /hub has to before the card can. It has never failed, but only because 6000ms is double the budget that did. It waits for the pill now, and still fails if the collapse genuinely did not survive.

A detector for that specific shape (nav -> fixed sleep -> positive presence assert, with no intervening wait_for_selector / expect / wait_for_load_state) over all 31 playwright_*.py found exactly one other hit, playwright_chat_ui.py:1854, which is a conditional branch rather than an assertion and cannot fail a suite. The heaviest users of wait_for_timeout -- playwright_chat_ui.py (40), playwright_find_in_page.py (40), playwright_nonmodal_menus.py (38) -- carry no instance. That is a targeted scan, not a full audit.

A failure should explain itself

The whole output of the one real occurrence was:

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

which is the one thing already known. check() already takes a detail; the presence checks now pass one:

wait=TimeoutError: Timeout 12000ms exceeded. pathname='/hub' card_nodes=0 collapsed_pill=0
root_children=0 auth_token=True show_pref='true' status_reads=7
console=['error: Failed to fetch dynamically imported module hub-abc.js']

Each probe separates a different cause: pathname a redirect or a route that never resolved, root_children an SPA that never mounted, auth_token a slip the /login guard in boot cannot catch on a mid-suite navigation, show_pref a preference that was not seeded, status_reads a poll that never fired, console a bundle that threw. Console messages are recorded rather than printed, cleared per navigation, capped at 200 chars each and the last 4 shown, so a passing run stays exactly as quiet as it is now.

On swallowing the wait

The exception still must not propagate: the caller's presence assertion is what decides pass or fail, and raising would turn a product verdict into a traceback that loses the remaining checks. But except Exception: pass swallowed it anonymously, merging two unrelated outcomes. A TimeoutError is a real verdict about the card. A closed target or navigation error means the run died for a reason with nothing to do with the card, and was reported identically as FAILED: card survives /hub. await_selector returns the class and first line so the detail can say which.

It also surfaces a third outcome the old pairing hid entirely: wait_for_selector waits for visible, count() counts attached, so a card that attaches and never becomes visible times out and passes. Latent today, since loaded-models-indicator.tsx:246 returns null rather than rendering hidden, so this logs a NOTE and changes no verdict.

One budget deliberately left alone

:591 and :605 wait 11,000ms for a card to appear or reopen via the 5s poll. Genuinely poll-bound, so a fixed wait is defensible, and :591 asserts absence, which a selector wait cannot express. 11s is only ~2.2 ticks, so it is the next candidate if anything there ever flakes; not changed here because nothing has.

Validation

Not exercised end to end. This box is Linux, so a playwright install webkit gives WebKitGTK rather than the macOS WebKit the job drives, and the driver also needs a built frontend and a running studio. What did run:

  • python -m py_compile on the driver
  • pytest tests/studio/test_playwright_suites_run_in_ci.py tests/studio/test_indicator_browsers_run_in_parallel.py -> 23 passed
  • pytest tests/test_enforce_kwargs_spacing.py -> 62 passed
  • no line over the repo's 119 limit
  • a stub-page unit test of why_no_card / await_selector covering the timeout, dead-browser, /login redirect and collapsed-pill cases

The Mac job on this PR is the real check.

…age looked like

#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.
@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-21T09:24:42.996966Z 1ef708f Manual request
ℹ️ 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[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
`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.
@danielhanchen danielhanchen self-assigned this Sep 21, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

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`.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 21, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 21, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 21, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 1ef708fb0d

ℹ️ 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".

@danielhanchen
danielhanchen merged commit fc86fd0 into main Sep 21, 2026
22 of 23 checks passed
@danielhanchen
danielhanchen deleted the fix/indicator-presence-check-diagnostics branch September 21, 2026 10:21
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