Skip to content

test: print a hung test's greenlet stacks before the half-hour timeout - #6982

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-6807-greenlet-dump
Nov 24, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-6807-greenlet-dump

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

When a test outlives faulthandler_timeout (30 minutes), the worker's dump lists every OS thread. Under Playwright's sync API, though, the test's own frames sit in a suspended greenlet, so the dump shows only Playwright's event loop and never the line whose call is waiting. #46 named this gap when it removed an earlier guard. It also left the one hang in #6807 (test_page_fixture_renders[feature-gallery] on macOS) with no location. Now, a minute before the timeout, tests/conftest.py prints the stack of every suspended greenlet to the run's own stderr, next to faulthandler's dump. It only prints: no test is failed and no worker is stopped.

To verify, I ran a scratch test that waits in page.evaluate("() => new Promise(() => {})") with -o faulthandler_timeout=75, under both -n0 and -n1. Before the change, the dump ended at playwright/sync_api/_context_manager.py ... greenlet_main. After it, the output also holds the greenlet's stack, ending at the scratch test's evaluate line. Then faulthandler's dump follows and the worker crashes as before. tests/model passes except for three test_codex_adapter.py cases that fail the same way on main in this sandbox (OSError: [Errno 97] Address family not supported).

The stderr written to is a copy of fd 2 taken at pytest_configure, because output capture redirects sys.stderr during a test and that output would be lost when the worker exits.

Refs #6807 — automated triage. This adds what the next hang will need for a diagnosis; it doesn't fix the hang, nor the document-scroll and quoting failures that issue also tracks.

faulthandler_timeout dumps every OS thread, but Playwright's sync API keeps
the test's own frames in a suspended greenlet, so a hung browser test's dump
shows only the event loop and never the line whose call is waiting. A minute
before the timeout, the conftest now prints every greenlet's stack to the
run's stderr. Nothing is stopped or failed by it.

Refs #6807
ty rejected sys.__stderr__.fileno() since sys.__stderr__ may be None;
fd 2 is the same descriptor, so behavior is unchanged.
@leaf-agent
leaf-agent merged commit 00fc0f0 into main Nov 24, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-6807-greenlet-dump branch November 24, 2026 08:15
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