Skip to content

feat(v2): add the sync API on top of playwright/_impl_v2 - #3277

Merged
Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:v2-polish
Oct 20, 2026
Merged

Pavel Feldman (pavelfeldman) merged 1 commit into
microsoft:mainfrom
pavelfeldman:v2-polish

Conversation

@pavelfeldman

@pavelfeldman Pavel Feldman (pavelfeldman) commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • PW_IMPL=v2 switches the sync API too: the greenlet mechanism of v1, shared. Every v2 object carries _loop and _dispatcher_fiber; channel listeners, route/WebSocket-route/binding/locator handlers run in greenlets of their own; a sync call's stack is read from the caller's frame on the task.
  • tests/sync runs under v2 (conftest, test scripts, the three v2 CI bots); the sync legacy tests get the @only_v1 marks of their async twins. transform.md section 13 documents the sync layer.
  • Listener errors are logged, not printed. Also the polish after the review of the port (instrumentation list, buffer validator, DEBUG matcher, test server finish(), test-v2.sh), and the lint checks run in the Lint job, not as a git hook.

PW_IMPL=v2 now switches the sync API too. It is the greenlet mechanism of v1,
shared by the two implementations (sync_api/_context_manager.py,
_impl/_sync_base.py, _impl/_greenlets.py): a dispatcher fiber runs the event
loop, and a sync call switches to it until its task is done.

- Every v2 object carries _loop and _dispatcher_fiber for the generated API.
  The connection runs each channel listener in an EventGreenlet; a route,
  WebSocket route, binding or locator handler runs through run_in_greenlet();
  a predicate runs in the listener. A callback that ran in the dispatcher
  fiber itself would spin in wait_for_future().
- A sync call runs in a task of the dispatcher, where the caller's stack is
  not visible: _sync() stores the caller's frame on the task, and
  capture_raw_stack() continues from it (API names, trace stacks).
- The stop path handles a driver that did not start or exited on its own.
- An error of an event listener is logged instead of printed, so that a test
  run is quiet and a plain script still gets it on stderr.
- tests/sync runs under PW_IMPL=v2: conftest, test.sh, test-v2.sh and the
  three v2 CI bots. The sync legacy tests get the @only_v1 marks of their
  async twins; the sync ports use the v2 matcher and _wrap_api_call() where
  the async ports do. The test scripts pass --maxschedchunk=1.
- transform.md, section 13, documents the sync layer.

Also the polish after the review of the port: the instrumentation list, the
buffer validator mode and the DEBUG matcher follow upstream; an error of the
eager part of an API call is raised as it is, without the API name (deliberate);
the test server ignores finish() after the client went away, BT-034 suppresses
Node's certificate warning. The lint checks run in the Lint job, not as a git
hook: the docs drop `pre-commit install`.
@pavelfeldman Pavel Feldman (pavelfeldman) changed the title chore(v2): polish after the review of the port feat(v2): add the sync API on top of playwright/_impl_v2 Oct 20, 2026
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 4e1ce7a into microsoft:main Oct 20, 2026
30 of 32 checks passed
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.

2 participants