feat: add Playwright support to browser-use extension - #5
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Partial init failure in ensureDriver leaks Chromium process
- Wrapped browser initialization in a cleanup catch so partially created Playwright resources are closed before the error is rethrown.
Or push these changes by commenting:
@cursor push 337502ca66
Preview (337502ca66)
diff --git a/extensions/browser-use/index.ts b/extensions/browser-use/index.ts
--- a/extensions/browser-use/index.ts
+++ b/extensions/browser-use/index.ts
@@ -284,11 +284,16 @@
return { page: state.page, cdp: state.cdp };
}
state.headed = headed ?? false;
- state.browser = await chromium.launch({ headless: !state.headed });
- state.context = await state.browser.newContext();
- state.page = await state.context.newPage();
- state.cdp = await state.context.newCDPSession(state.page);
- return { page: state.page, cdp: state.cdp };
+ try {
+ state.browser = await chromium.launch({ headless: !state.headed });
+ state.context = await state.browser.newContext();
+ state.page = await state.context.newPage();
+ state.cdp = await state.context.newCDPSession(state.page);
+ return { page: state.page, cdp: state.cdp };
+ } catch (error) {
+ await closeDriver(state);
+ throw error;
+ }
}
async function closeDriver(state: DriverState): Promise<void> {You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 30e4f50. Configure here.
| interactive: Type.Optional(Type.Boolean({ description: "Only include interactive elements." })), | ||
| urls: Type.Optional(Type.Boolean({ description: "Include href URLs for links in the snapshot." })), | ||
| compact: Type.Optional(Type.Boolean({ description: "Remove empty structural elements." })), | ||
| depth: Type.Optional(Type.Number({ description: "Optional maximum tree depth.", minimum: 1 })), |
There was a problem hiding this comment.
Partial init failure in ensureDriver leaks Chromium process
Low Severity
If chromium.launch succeeds but a subsequent step (newContext, newPage, or newCDPSession) throws, state.browser is set while state.page/state.cdp remain undefined. On the next call, ensureDriver sees the state.page && state.cdp guard as falsy and launches a brand-new browser, overwriting state.browser and orphaning the previous Chromium process. Neither closeDriver nor the session_shutdown handler can ever reach the leaked instance.
Reviewed by Cursor Bugbot for commit 30e4f50. Configure here.



Note
Medium Risk
Large behavioral and API change (steps→actions, different ref semantics) plus a new runtime dependency (
playwright) and persistent browser lifecycle, which could affect existing integrations and resource cleanup.Overview
Replaces the
browser-useextension’sagent-browser/CLI-based implementation with an in-process Playwright (Chromium) driver that returns a text-only CDP accessibility tree and executes interactions via regenerated ref IDs.The
browsertool API changes fromstepsto a boundedactionslist (1–7) and narrows supported operations togoto,snapshot,click,fill,press,scroll, andwait, updating output formatting to include URL/title/ref count plus the rendered accessibility tree. Lifecycle handling is added to keep a persistent browser across calls and cleanly close it onsession_shutdown, and repo dependencies/docs are updated to addplaywrightand new setup instructions.Reviewed by Cursor Bugbot for commit 30e4f50. Bugbot is set up for automated code reviews on this repo. Configure here.