Repository navigation
Report a Playwright driver that never starts as one line, not a traceback - #725
Merged
Merged
Conversation
…back Both browser gates guard the launch and neither guards the step before it. Where Playwright's driver process ends at startup, `sync_playwright()`'s context entry raises an AttributeError naming a Playwright private and the real reason arrives afterwards as an unretrieved asyncio task, so a host with an old glibc or an old PLAYWRIGHT_NODEJS_PATH Node reads a leaf bug. `playwright_driver()` enters that context, reads the connection's init task for the reason, and raises DriverNotStarted. Each gate reports it in its own words beside the failed-launch line, naming the Node that ran and the variable that chooses one, and exits 1. Closes #724
leaf-agent
commented
Sep 15, 2026
leaf-agent
left a comment
Collaborator
Author
There was a problem hiding this comment.
One finding, inline: the new context manager exits a Playwright manager whose start() failed, which turns a mistyped PLAYWRIGHT_NODEJS_PATH into an AttributeError from Playwright's own cleanup — the shape this PR exists to remove, on the variable it exists to name. I'm pushing the fix to this branch, so it needs no decision from you.
Exiting a Playwright manager whose start() failed is the one thing the with statement never did: where the spawn fails, Playwright's stop asserts a transport handle it never assigned, so the cleanup's own AttributeError replaced the missing file as the reason. Leave that manager unexited, and read a failed spawn as the same DriverNotStarted the silent driver raises, so a PLAYWRIGHT_NODEJS_PATH naming a Node that is not there gets the one line too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
version check --renderandversion exporteach guard the browser launch, butnot Playwright's driver — the Node process that launch talks to. When that
process ends at startup,
sync_playwright()'s context entry returnsself._playwright, which the connection callback never assigned, so the commanddies on
AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'. The actual reason,Connection.init: Connection closed while reading from the driver, is printed afterwards and out of order as asyncio'sTask exception was never retrieved.The two hosts that reach it are ordinary: a glibc older than the Node bundled in
the Playwright wheel needs, and a
PLAYWRIGHT_NODEJS_PATHnaming a Node olderthan the driver bundle needs. Neither failure names that variable, which is the
line that settles both in seconds.
Solution
playwright_driver()inrender_gate/browser.pyenters the context itself.On the AttributeError it reads the connection's init task for the reason and
raises
DriverNotStartedcarrying it — and reading that task is also what keepsasyncio from printing the second traceback at all. Each gate catches it beside
its existing failed-launch guard and prints one line, in its own words, with the
reason, the Node that ran, and the variable that chooses one:
A third host names a Node it does not have. The driver never runs at all there, so the spawn fails a step earlier than the silence above, and that OSError is read as the same
DriverNotStarted, carrying the missing file. Its manager is left unentered and unexited, aswithleft one whose__enter__raised: Playwright's stop asserts a transport handle the failed spawn never assigned, so exiting a failed entry answers with a private of its own instead of the file that is not there.Both exit 1, as they did.
driver_node()reads the two paths Playwright itselfreads — the variable, else the wheel's bundled
driver/node— from thepackage's own location rather than through
playwright._impl._driver, becausethis runs only where the driver already failed and a moved private would put the
traceback back. The interactive export path needs no browser and is untouched.
Testing
test_a_driver_that_never_starts_is_reported_rather_than_raiseddrives bothcommands with
PLAYWRIGHT_NODEJS_PATHnaming a stub that exits withoutanswering, and asserts the one line plus the absence of all three shapes the
reader sees today — the raised private, the asyncio block, and any traceback.
Against the pre-fix source it fails on the raw traceback; it passes here.
Its third arm names a Node that does not exist and asserts the same shape, which fails on the cleanup's own
_outputprivate without the fix.test_an_unnamed_driver_node_is_the_installed_wheels_owncovers the hint'sother arm, which the subprocess cannot reach.
The browser-gate happy path could not be exercised in this CI sandbox — Chrome
does not launch here, and
test_check_render_refuses_what_only_a_browser_can_seefails identically on unmodified
main— so PR CI is the first run of it. Thecontext manager was verified equivalent out of band: entering and exiting
playwright_driver()produces byte-identical output to entering and exitingsync_playwright()on the same host.Closes #724 — automated triage