diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 882e7c455..931119763 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -1389,6 +1389,7 @@ class Playwright extends Helper { } } + // Close browserContext if recordHar is enabled if (this.options.recordHar && this.browserContext) { try { await this.browserContext.close() @@ -1398,16 +1399,16 @@ class Playwright extends Helper { } this.browserContext = null + // Initiate browser close without waiting for it to complete + // The browser process will be cleaned up when the Node process exits if (this.browser) { try { - // Add timeout to prevent browser.close() from hanging indefinitely - await Promise.race([this.browser.close(), new Promise((_, reject) => setTimeout(() => reject(new Error('Browser close timeout')), 5000))]) + // Fire and forget - don't wait for close to complete + this.browser.close().catch(() => { + // Silently ignore any errors during async close + }) } catch (e) { - // Ignore errors if browser is already closed or timeout - if (!e.message?.includes('Browser close timeout')) { - // Non-timeout error, can be ignored as well - } - // Force cleanup even on error + // Ignore any synchronous errors } } this.browser = null