codeceptjs 4.0.1-beta.13 → 4.0.1-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/helper/Playwright.js +8 -30
- package/package.json +1 -1
package/lib/helper/Playwright.js
CHANGED
|
@@ -1389,29 +1389,7 @@ class Playwright extends Helper {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
}
|
|
1391
1391
|
|
|
1392
|
-
// Close
|
|
1393
|
-
if (this.browser) {
|
|
1394
|
-
try {
|
|
1395
|
-
const contexts = await Promise.race([
|
|
1396
|
-
this.browser.contexts(),
|
|
1397
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Get contexts timeout')), 1000))
|
|
1398
|
-
])
|
|
1399
|
-
// Close all pages in all contexts first
|
|
1400
|
-
await Promise.allSettled(contexts.map(async (ctx) => {
|
|
1401
|
-
try {
|
|
1402
|
-
const pages = await ctx.pages()
|
|
1403
|
-
await Promise.allSettled(pages.map(p => p.close().catch(() => {})))
|
|
1404
|
-
} catch (e) {
|
|
1405
|
-
// Ignore errors getting or closing pages
|
|
1406
|
-
}
|
|
1407
|
-
}))
|
|
1408
|
-
// Then close all contexts
|
|
1409
|
-
await Promise.allSettled(contexts.map(c => c.close().catch(() => {})))
|
|
1410
|
-
} catch (e) {
|
|
1411
|
-
// Ignore errors if browser is already closed or timeout getting contexts
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1392
|
+
// Close browserContext if recordHar is enabled
|
|
1415
1393
|
if (this.options.recordHar && this.browserContext) {
|
|
1416
1394
|
try {
|
|
1417
1395
|
await this.browserContext.close()
|
|
@@ -1421,16 +1399,16 @@ class Playwright extends Helper {
|
|
|
1421
1399
|
}
|
|
1422
1400
|
this.browserContext = null
|
|
1423
1401
|
|
|
1402
|
+
// Initiate browser close without waiting for it to complete
|
|
1403
|
+
// The browser process will be cleaned up when the Node process exits
|
|
1424
1404
|
if (this.browser) {
|
|
1425
1405
|
try {
|
|
1426
|
-
//
|
|
1427
|
-
|
|
1406
|
+
// Fire and forget - don't wait for close to complete
|
|
1407
|
+
this.browser.close().catch(() => {
|
|
1408
|
+
// Silently ignore any errors during async close
|
|
1409
|
+
})
|
|
1428
1410
|
} catch (e) {
|
|
1429
|
-
// Ignore
|
|
1430
|
-
if (!e.message?.includes('Browser close timeout')) {
|
|
1431
|
-
// Non-timeout error, can be ignored as well
|
|
1432
|
-
}
|
|
1433
|
-
// Force cleanup even on error
|
|
1411
|
+
// Ignore any synchronous errors
|
|
1434
1412
|
}
|
|
1435
1413
|
}
|
|
1436
1414
|
this.browser = null
|