Skip to content

Commit

Permalink
fix(core): mute puppeteer headless new warnings
Browse files Browse the repository at this point in the history
Summary:
## Before
Puppeteer showing warning messages when running MemLab:
 {F1075018402}

## After
No warning messages:
 {F1075018416}

Differential Revision: D48610311

fbshipit-source-id: 9a535a89c9bbe31dd8bf836aadda09e1b9f0f6be
  • Loading branch information
JacksonGL authored and facebook-github-bot committed Aug 24, 2023
1 parent 85aceb0 commit a114be4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/api/src/__tests__/heap/lib/HeapParserTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async function dumpHeap(
snapshotFile: string,
leakInjector: () => void,
): Promise<void> {
utils.tryToMutePuppeteerWarning();
const browser = await puppeteer.launch(config.puppeteerConfig);
const page = await browser.newPage();
// set page size
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/lib/APIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function getBrowser(
): Promise<Browser> {
const runConfig = options.config ?? config;
let browser: Browser;
utils.tryToMutePuppeteerWarning();
if (runConfig.isLocalPuppeteer && !options.warmup) {
try {
browser = await puppeteer.connect({
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,16 @@ function objectToMap(object: StringRecord): Map<string, string> {
return ret;
}

function tryToMutePuppeteerWarning() {
if (process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'] == null) {
info.lowLevel(
'Setting env variable PUPPETEER_DISABLE_HEADLESS_WARNING=1 ' +
'to mute puppeteer warnings.',
);
process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'] = '1';
}
}

export default {
aggregateDominatorMetrics,
applyToNodes,
Expand Down Expand Up @@ -2203,5 +2213,6 @@ export default {
shouldShowMoreInfo,
shuffleArray,
throwError,
tryToMutePuppeteerWarning,
upperCaseFirstCharacter,
};

0 comments on commit a114be4

Please sign in to comment.