Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lambdatest/smartui-cli",
"version": "4.1.77",
"version": "4.1.78",
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
"files": [
"dist/**/*"
Expand Down
3 changes: 3 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export default {
// Default page load time
DEFAULT_PAGE_LOAD_TIMEOUT: 180000,

// Cap on page/context teardown; a crashed target never returns from close().
BROWSER_CLOSE_TIMEOUT: 15000,

// Magic Numbers
MAGIC_NUMBERS: [
{ ext: 'jpg', magic: Buffer.from([0xFF, 0xD8, 0xFF]) },
Expand Down
14 changes: 12 additions & 2 deletions src/lib/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,18 @@ async function captureScreenshotsForConfig(
} catch (error) {
throw new Error(`captureScreenshotsForConfig failed for browser ${browserName}; error: ${error}`);
} finally {
await page?.close();
await context?.close();
// A crashed target never resolves close(), which would strand this capture and block
// finalizeBuild. Abandoning it is safe: closeBrowsers() kills the browser process after.
const closed = await Promise.race([
(async () => { await page?.close(); await context?.close(); return true; })().catch(() => true),
new Promise<boolean>(resolve => {
const timer = setTimeout(() => resolve(false), constants.BROWSER_CLOSE_TIMEOUT);
(timer as any).unref?.();
})
]);
if (!closed) {
ctx.log.warn(`${browserName}: page/context close timed out after ${constants.BROWSER_CLOSE_TIMEOUT}ms; abandoning it`);
}
}

}
Expand Down