Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
Loading