fix: Upgrade browser-commander to v0.5.3 (fixes Playwright evaluate bug)#149
fix: Upgrade browser-commander to v0.5.3 (fixes Playwright evaluate bug)#149
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #148
…uate Fixes #148 ## Problem When using Playwright engine with multiple arguments passed to safeEvaluate(), the automation crashed with: "SyntaxError: Failed to execute 'querySelectorAll' on 'Document': '[data-qa="vacancy-serp__vacancy_response"],' is not a valid selector." ## Root Cause The browser-commander v0.3.0 package's PlaywrightAdapter.evaluateOnPage() incorrectly passes multiple arguments as a single array to page.evaluate(). Playwright's evaluate() only accepts a single argument, so the function receives the entire array as its first parameter instead of spread arguments. When this array is passed to document.querySelectorAll(), JavaScript converts it to a string using toString(), which joins elements with commas. An empty array (like processedIds = []) becomes an empty string, resulting in a trailing comma. Evidence: ["selector", []].toString() => "selector," ## Solution Added a patch for browser-commander using patch-package that fixes the PlaywrightAdapter.evaluateOnPage() method to properly handle multiple args: 1. Convert the function to a string 2. Pass function string + args array as a single object to browser context 3. Reconstruct the function in browser and call with spread arguments This makes Playwright's behavior match Puppeteer's spread behavior without requiring changes to any call sites. ## Changes - patches/browser-commander+0.3.0.patch: Fix for multi-arg evaluate - package.json: Added patch-package devDependency and postinstall script ## Testing - All 327 tests pass - Lint passes - experiments/test-playwright-multi-args.mjs validates the fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit e9eb50e.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Please report issue there at: https://github.com/link-foundation/browser-commander The issue must contain reproducible examples, workarounds and suggestions for fix the issue in code. So once it is fixed there we will be able to remove workaround here. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-08T19:44:43.630Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
|
I've created the upstream issue as requested: link-foundation/browser-commander#15 The issue contains:
Once the fix is merged upstream and a new version is released, we can remove the patch from this repository. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
There is new version available - https://github.com/link-foundation/browser-commander/releases/tag/v0.5.1, will it work as expected? Everything is solved? |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-09T15:03:25.809Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Investigation ResultI investigated the browser-commander v0.5.1 release status: ✅ Good News
❌ Problem FoundThe npm publishing failed for v0.5.1. From the CI logs: The npm token has been revoked due to npm's security policy change (classic tokens were revoked, granular tokens now require 2FA and 90-day limits). Current npm status:
Action TakenI've created a new issue to report this: link-foundation/browser-commander#17 Next StepsOnce the npm token is refreshed and v0.5.1 is published to npm, we can:
For now, the patch in this PR remains necessary as a workaround until the upstream package is available on npm. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Now it is released, check again. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-10T14:31:12.752Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
The upstream fix for Playwright's evaluateOnPage() trailing comma bug has been released in browser-commander v0.5.1+ and is now available on npm. Changes: - Upgraded browser-commander from ^0.3.0 to ^0.5.3 - Removed patch-package and the browser-commander patch file - Removed postinstall script that applied patches - Removed test experiment script The upstream fix in v0.5.1 addresses the same issue we were patching: properly spreading multiple arguments to Playwright's evaluate() by reconstructing the function in the browser context. All 327 tests pass with the upstream fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Issue Resolved with Upstream FixThe issue has been resolved by upgrading to browser-commander v0.5.3, which includes the upstream fix for the Playwright multi-argument evaluation bug. What Changed
Verification
Upstream Fix DetailsThe fix was released in:
The upstream issue was tracked at: link-foundation/browser-commander#15 This PR is now ready for final review and merge. |
Summary
Fixes #148
Upgraded
browser-commanderfrom v0.3.0 to v0.5.3, which includes the upstream fix for the Playwright multi-argument evaluation bug.Problem
When using Playwright engine with multiple arguments passed to
safeEvaluate(), the automation crashed with:Root Cause
The
browser-commanderv0.3.0 package'sPlaywrightAdapter.evaluateOnPage()incorrectly passed multiple arguments as a single array topage.evaluate(). Since Playwright only accepts a single argument, the function received the entire array as its first parameter instead of spread arguments.When this array was passed to
document.querySelectorAll(), JavaScript converted it to a string usingtoString(), which joins elements with commas. An empty array becomes an empty string, resulting in a trailing comma:Solution
The upstream fix was released in
browser-commanderv0.5.1 and published to npm. The fix modifiesPlaywrightAdapter.evaluateOnPage()to:This makes Playwright's behavior match Puppeteer's spread behavior without requiring changes to any call sites.
Changes
browser-commanderfrom^0.3.0to^0.5.3patch-packagefrom devDependenciespatches/browser-commander+0.3.0.patchfilepostinstallscript that applied patchesUpstream Issue
The fix was implemented upstream in: link-foundation/browser-commander#16
Test Plan
🤖 Generated with Claude Code