-
Notifications
You must be signed in to change notification settings - Fork 35
ad hoc playwright code exec API #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ad hoc playwright code exec API #84
Conversation
Co-authored-by: null <>
Mesa Description
Note Adds POST /playwright/execute to run user TypeScript/Playwright code via tsx against Chromium, updates images with Node.js 22 + Playwright, and includes an e2e test.
Written by Cursor Bugbot for commit 8251b07. This will update automatically on new commits. Configure here. Description generated by Mesa. Update settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performed full review of 174e365...e809a85
Tip
Help
Slash Commands:
/review- Request a full code review/review latest- Review only changes since the last review/describe- Generate PR description. This will update the PR body or issue comment depending on your configuration/help- Get help with Mesa commands and configuration options
7 files reviewed | 0 comments | Edit Agent Settings
hiroTamada
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the point of this making the playwright code and chrome physically close to each other to avoid network connectivity issue and latency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, does it make the image bigger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes by 200-300 MB
|
I actually wonder if this endpoint is thread safe or not. Would concurrent script executions break chrome? |
yes, exactly! |
## Overview Following up on #84. Install and allow running against patchright instead of only playwright ## Testing Build + ran both headful + headless images. Confirmed execution working as expected with `curl`: ```sh curl -sS http://localhost:444/playwright/execute \ -H 'Content-Type: application/json' \ -d '{"code":"await page.goto(\"https://example.com\"); return await page.title();"}' {"result":"Example Domain","success":true} ``` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds Patchright support across images and runtime, selectable via PLAYWRIGHT_ENGINE, and tweaks headless Chromium flags. > > - **Runtime** > - Update `server/runtime/playwright-executor.ts` to dynamically select `chromium` from `patchright` or `playwright-core` based on `PLAYWRIGHT_ENGINE`. > - **Images** > - Install `patchright` globally alongside `playwright-core`, `typescript`, and `tsx` in `images/chromium-headful/Dockerfile` and `images/chromium-headless/image/Dockerfile`. > - **Scripts** > - Pass through `PLAYWRIGHT_ENGINE` env in `images/chromium-headful/run-docker.sh` and `images/chromium-headless/run-docker.sh`. > - **Chromium Flags (Headless)** > - Adjust defaults in `images/chromium-headless/image/wrapper.sh` by removing several flags (e.g., `--disable-component-update`, `--disable-default-apps`, `--disable-extensions`, `--enable-automation`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 50d5bb3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
pagePlaywright objectNote
Adds /playwright/execute API to run TypeScript/Playwright code against the running Chromium via a tsx-based executor, and installs Node.js 22 + Playwright tooling in images.
POST /playwright/executeto run arbitrary TS/Playwright code with timeout; serializes runs viaApiService.playwrightMu.ExecutePlaywrightCodeexecutingtsx /usr/local/lib/playwright-executor.ts <tmp.ts>and returning JSON{success,result|error,stdout,stderr}.ExecutePlaywrightRequest/Result).server/runtime/playwright-executor.tsconnecting tows://127.0.0.1:9222viaplaywright-core, exposingpage/context/browser, returning JSON.npm/npx/corepacklinks; globally installstypescript,playwright-core,tsxin bothchromium-headfulandchromium-headlessimages.playwright-executor.tsinto/usr/local/lib/.TestPlaywrightExecuteAPIvalidating navigation to example.com and returned title.openapi.yamland embedded swagger; regeneratesserver/lib/oapi.Written by Cursor Bugbot for commit aaccaeb. This will update automatically on new commits. Configure here.