diff --git a/packages/core/lib/v3/understudy/context.ts b/packages/core/lib/v3/understudy/context.ts index f1c70e16f..fca58500e 100644 --- a/packages/core/lib/v3/understudy/context.ts +++ b/packages/core/lib/v3/understudy/context.ts @@ -174,7 +174,14 @@ export class V3Context { opts?.localBrowserLaunchOptions ?? null, ); await ctx.bootstrap(); - await ctx.ensureFirstTopLevelPage(getFirstTopLevelPageTimeoutMs()); + // Allow connectTimeoutMs to also govern how long we wait for the first + // top-level page to appear. On slow machines the browser may need more + // time after the CDP socket is open before the initial page registers. + const firstPageTimeoutMs = Math.max( + opts?.localBrowserLaunchOptions?.connectTimeoutMs ?? 0, + getFirstTopLevelPageTimeoutMs(), + ); + await ctx.ensureFirstTopLevelPage(firstPageTimeoutMs); return ctx; };