From 3024612da0c5f24bfc2c4c515e2f5e89b5e8cdbc Mon Sep 17 00:00:00 2001 From: Eryk Kolodziej Date: Tue, 28 May 2024 11:58:37 -0700 Subject: [PATCH] feat(core): add config to skip waiting for browser close (#120) Summary: Issue: https://github.com/facebook/memlab/issues/95 Pull Request resolved: https://github.com/facebook/memlab/pull/120 Test Plan: ``` memlab build-core && memlab test && arc lint ``` Reviewed By: twobassdrum Differential Revision: D57819075 Pulled By: JacksonGL fbshipit-source-id: e60d1aa9d8b59565534a660bb029ceb68499b3d6 --- packages/core/src/lib/Config.ts | 3 +++ packages/core/src/lib/Utils.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/packages/core/src/lib/Config.ts b/packages/core/src/lib/Config.ts index 91f176a6..fb90af51 100644 --- a/packages/core/src/lib/Config.ts +++ b/packages/core/src/lib/Config.ts @@ -240,6 +240,7 @@ export class MemLabConfig { noReCluster: boolean; maxSamplesForClustering: number; filterTraceByName: Nullable; + skipBrowserCloseWait: boolean; constructor(options: ConfigOption = {}) { // init properties, they can be configured manually @@ -370,6 +371,8 @@ export class MemLabConfig { // if specified via CLI options, this will filter leak traces by // node and edge names in the leak trace this.filterTraceByName = null; + // if true, memlab will not wait for the browser to close successfully + this.skipBrowserCloseWait = false; } // initialize configurable parameters diff --git a/packages/core/src/lib/Utils.ts b/packages/core/src/lib/Utils.ts index 0a5a3b66..7aed3873 100644 --- a/packages/core/src/lib/Utils.ts +++ b/packages/core/src/lib/Utils.ts @@ -1325,6 +1325,8 @@ async function closePuppeteer( if (config.isLocalPuppeteer && !options.warmup) { await Promise.all(pages.map(page => page.close())); await browser.disconnect(); + } else if (config.skipBrowserCloseWait) { + browser.close(); } else { await browser.close(); }