Skip to content

Multi-account Playwright: an aborted /login must not use up the stalled-load retry - #16768

Merged
danielhanchen merged 2 commits into
mainfrom
multi-account-login-abort-then-timeout
Nov 5, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
multi-account-login-abort-then-timeout

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Chat UI Tests (extra) fails on unrelated PRs several times a day at the same place, for example #16722, #16741 and the staging run for #16750:

File "tests/studio/playwright_multi_account.py", line 173, in run
    open_login(page)
File "tests/studio/playwright_multi_account.py", line 67, in open_login
    page.goto(url)
playwright._impl._errors.TimeoutError: Page.goto: Timeout 30000ms exceeded.
Call log:
  - navigating to "http://127.0.0.1:18894/login", waiting until "load"

#16437 added a recorded retry for exactly this stalled /login load, but it never runs in these failures. None of the failing logs print its WARN: /login did not fire load ... line, and the whole step lasts about 33 s, i.e. one 30 s timeout. open_login gives aborts and timeouts one shared two-attempt budget: right after a log-out the app's own 401 redirect (redirectToAuth) aborts the first goto with ERR_ABORTED, which spends attempt 1, and the stalled load then happens on attempt 2, where it is fatal.

Change

tests/studio/playwright_multi_account.py, open_login only:

  • Aborts and timeouts each get their own single retry, so an abort can no longer use up the retry Multi-account Playwright: record and retry once when the post-logout /login load never fires #16437 added for a stalled load. A second abort, a second timeout, or any other error still fails the run as before.
  • When the abort came from the app's redirect and that redirect has already loaded /login, the page is used as it is instead of navigating to /login a second time. A redirect that ends anywhere else (for example /change-password) still navigates to /login.

Nothing outside this Playwright driver changes.

tests/studio/test_playwright_multi_account_open_login.py drives open_login with a scripted page and the real Playwright error types:

goto outcomes expected
abort, redirect already on /login returns after one goto
abort elsewhere, timeout, load returns after the third goto (the CI failure)
abort to /change-password, load navigates to /login
two aborts / two timeouts / abort then two timeouts raises
an error other than an abort raises, no retry

Testing

  • New test: 7 passed. Against the driver on main: 3 failed, including test_a_timeout_after_an_abort_still_gets_its_retry, the sequence the CI logs show.
  • tests/test_ci_repo_cpu_shards.py, tests/studio/test_playwright_suites_run_in_ci.py and tests/studio/test_pwsh_calls_use_the_shared_runner.py pass.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T11:09:01.011889Z c88ef38 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 59c7c888f1

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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: c88ef383d7

ℹ️ 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 66c239a into main Nov 5, 2026
@danielhanchen
danielhanchen deleted the multi-account-login-abort-then-timeout branch November 5, 2026 11:14
danielhanchen added a commit that referenced this pull request Nov 5, 2026
…b cannot break it (#16784)

## Summary

#16768 added `tests/studio/test_playwright_multi_account_open_login.py`,
and all 7 of its tests fail in `Repo tests (CPU, studio)` when an
earlier test in the same worker has stubbed Playwright, for example the
staging run for #16613:

```
test_a_redirect_that_already_loaded_login_is_used
E   RuntimeError: playwright is not installed: Error needs a real browser
E   TypeError: catching classes that do not inherit from BaseException is not allowed
test_a_second_failure_of_the_same_kind_is_real[two aborts]
E   TypeError: Expected a BaseException type, but got 'function'
7 failed, 10029 passed
```

The CPU jobs do not install Playwright.
`tests/studio/test_heavy_thread_measurement_integrity.py` handles that
by putting a stub `playwright.sync_api` into `sys.modules` that answers
every name with a function that raises. My test guarded with
`pytest.importorskip("playwright.sync_api")`, which finds that stub, so
it ran with functions where it expected exception types. Run alone, or
with real Playwright installed, it passed, which is why #16768's own
checks were green.

## Change

`tests/studio/test_playwright_multi_account_open_login.py` only. The
test no longer imports Playwright. It defines `Error` and
`TimeoutError(Error)` itself, matching Playwright's own hierarchy, and
while loading the driver it puts a minimal `playwright.sync_api`
carrying them into `sys.modules` through `monkeypatch`, which restores
the previous modules after each test. The test now runs, rather than
skips, on the CPU jobs, whatever earlier tests left behind. The driver
and the test cases are unchanged.

## Testing

With Playwright made unimportable and
`test_heavy_thread_measurement_integrity.py` run first in the same
process, as on CI:

| | result |
|---|---|
| main | 7 failed, 76 passed (the errors above) |
| this branch | 83 passed |

- With the real Playwright installed: 7 passed.
- Against the driver from before #16768: 3 failed, so the test still
guards the abort and timeout budgets.
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