fix(browser): handle daemon returning { session, data } wrapper from screenshot#1502
fix(browser): handle daemon returning { session, data } wrapper from screenshot#1502ddandyy74 wants to merge 1 commit into
Conversation
…screenshot
The daemon's screenshot command returns the base64 data wrapped in an object with session info ({ session, data }). The page.screenshot() method passed this object directly to saveBase64ToFile() which calls Buffer.from(base64, 'base64'), causing a TypeError on Windows. Fix by extracting the data field when the return value is an object, matching the pattern already used in cdp.ts. Closes #N/A
|
Thanks @ddandyy74 — your repro and analysis nailed a real bug. We hit the same We landed a root-cause fix earlier today in #1518 (commit We went with an extension-side fix rather than a client-side unwrap for two reasons:
Closing this PR as superseded — the fix will ship in the next release (1.7.19, in flight now). Once you upgrade with Really appreciate the contribution. If you run into more rough edges, especially around browser primitives or adapters, please keep reports / PRs coming — they're the kind of issue that's hard to spot internally because we usually catch the symptom on a different handler. |
Description
The daemon'"'"'s screenshot command returns the base64 data wrapped in an object with session info (
{ session, data }), butpage.screenshot()passes the return value directly tosaveBase64ToFile()which callsBuffer.from(base64, '"'"'base64'"'"').When the value is an object instead of a string, this causes
TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object.Fix
Extract the
datafield when the return value is an object with a stringdataproperty, matching the pattern already used incdp.ts. Falls back to treating the return value as a string for backward compatibility.Tested
opencli browser --session test screenshot output.png— saves PNG file correctlyopencli browser --session test screenshot— returns base64 string in console--full-pageflagRelated
This follows the same defensive pattern used in
src/browser/cdp.ts:246.