diff --git a/packages/scanner-global-library/src/page.ts b/packages/scanner-global-library/src/page.ts index afc3beeef..af64dc321 100644 --- a/packages/scanner-global-library/src/page.ts +++ b/packages/scanner-global-library/src/page.ts @@ -215,8 +215,17 @@ export class Page { } public async getPageSnapshot(): Promise { + const maxSnapshotSize = 10 * 1024 * 1024; try { - const { data } = await this.devToolsSession.send(this.page, 'Page.captureSnapshot', { format: 'mhtml' }); + let { data } = await this.devToolsSession.send(this.page, 'Page.captureSnapshot', { format: 'mhtml' }); + const length = Buffer.byteLength(JSON.stringify(data), 'utf8'); + if (length > maxSnapshotSize) { + this.logger?.logWarn(`Page snapshot exceeded maximum supported size of ${maxSnapshotSize / (1024 * 1024)} MB`, { + snapshotSize: length.toString(), + }); + + data = ''; + } return data; } catch (error) {