Restricted page snapshot size (#2552)
#### Details Restricted page snapshot size #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [ ] Addresses an existing issue: Fixes #0000 - [ ] Added relevant unit test for your changes. (`yarn test`) - [ ] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage` - [ ] Ran precheckin (`yarn precheckin`) - [ ] Validated in an Azure resource group
This commit is contained in:
Родитель
b9fc988cca
Коммит
6316c7da8e
|
@ -215,8 +215,17 @@ export class Page {
|
|||
}
|
||||
|
||||
public async getPageSnapshot(): Promise<string> {
|
||||
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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче