-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): support setting Chromium protocol timeout in CLI (#107)
Summary: Allow tweaking the Chromium protocol timeout for page crashed with error: 'ProtocolError: HeapProfiler.takeHeapSnapshot timed out'. Differential Revision: D52742549 fbshipit-source-id: 21b5cfb3b4f1d2bd88a478012185f34505b3e453
- Loading branch information
1 parent
6c82dea
commit 73c9fa3
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/cli/src/options/e2e/SetChromiumProtocolTimeoutOption.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @oncall web_perf_infra | ||
*/ | ||
import type {ParsedArgs} from 'minimist'; | ||
import {MemLabConfig} from '@memlab/core'; | ||
|
||
import {info, utils, BaseOption} from '@memlab/core'; | ||
import optionConstants from '../lib/OptionConstant'; | ||
|
||
export default class SetChromiumProtocolTimeoutOption extends BaseOption { | ||
getOptionName(): string { | ||
return optionConstants.optionNames.CHROMIUM_PROTOCOL_TIMEOUT; | ||
} | ||
|
||
getDescription(): string { | ||
return ( | ||
'set the protocol timeout for chromium connection (in ms). \n' + | ||
'The current default value is 180000, you may want to increase the ' + | ||
'timeout via this flag when the heap snapshot is ' + | ||
'too big (e.g., over 1GB) and the Page crashed with error: ' + | ||
"'ProtocolError: HeapProfiler.takeHeapSnapshot timed out'." | ||
); | ||
} | ||
|
||
async parse(config: MemLabConfig, args: ParsedArgs): Promise<void> { | ||
const name = this.getOptionName(); | ||
const arg = args[name]; | ||
if (arg) { | ||
const timeout = parseInt(arg, 10); | ||
if (Number.isNaN(timeout)) { | ||
utils.haltOrThrow( | ||
`Invalid Chromium protocol timeout value: ${arg}. ` + | ||
'It must be a number.', | ||
); | ||
} | ||
if (config.verbose) { | ||
info.lowLevel(`Set Chromium protocol timeout to ${timeout}.`); | ||
} | ||
config.puppeteerConfig.protocolTimeout = timeout; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters