From 777b109014d19c3673517a18a388a88d26e56304 Mon Sep 17 00:00:00 2001 From: dd Date: Tue, 12 May 2026 15:53:08 +0800 Subject: [PATCH] fix(browser): handle daemon returning { session, data } wrapper from 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 --- src/browser/page.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/browser/page.ts b/src/browser/page.ts index 01b4cb01b..4bbdd3497 100644 --- a/src/browser/page.ts +++ b/src/browser/page.ts @@ -216,14 +216,18 @@ export class Page extends BasePage { * Capture a screenshot via CDP Page.captureScreenshot. */ async screenshot(options: ScreenshotOptions = {}): Promise { - const base64 = await sendCommand('screenshot', { + const raw = await sendCommand('screenshot', { ...this._cmdOpts(), format: options.format, quality: options.quality, fullPage: options.fullPage, width: options.width, height: options.height, - }) as string; + }); + + const base64 = typeof raw === 'object' && raw !== null && typeof (raw as Record).data === 'string' + ? (raw as Record).data as string + : raw as string; if (options.path) { await saveBase64ToFile(base64, options.path);