@@ -72,18 +72,7 @@ export interface PageReadyPage {
7272}
7373
7474export interface WaitForPageReadyOptions {
75- /**
76- * Wall-clock ceiling shared by the idle waits and the readyState poll —
77- * each wait gets only the time still left. Pass the remaining capture
78- * budget (min'd with 15_000) so the settle cannot outrun the stage.
79- */
8075 timeoutMs ?: number ;
81- /**
82- * "always" pays one bounded idle wait up front — the post-click settle,
83- * where a navigation or consent XHR is expected. "after-load" skips that
84- * wait and idles only when the poll actually saw a loading document — a
85- * cheap guard for stages that already settled the page.
86- */
8776 networkIdle ?: "always" | "after-load" ;
8877}
8978
@@ -96,18 +85,11 @@ export async function waitForPageReady(
9685 const remaining = ( ) => Math . max ( 0 , deadline - Date . now ( ) ) ;
9786 const idle = ( ) =>
9887 page
99- // concurrency: 2 matches the networkidle2 semantic navigation already
100- // uses, so one held-open request (long-poll, beacon) cannot block it.
10188 . waitForNetworkIdle ( { idleTime : 500 , timeout : remaining ( ) , concurrency : 2 } )
10289 . catch ( ( ) => { } ) ;
10390
10491 if ( networkIdle === "always" && remaining ( ) > 0 ) await idle ( ) ;
10592
106- // Poll the document out of a still-loading or mid-navigation state. The
107- // bound is wall clock, not iteration count: each evaluate races the
108- // remaining deadline, so a hung execution-context wait (~30s, or the
109- // protocol timeout) cannot stretch the settle. Degradable protocol/stage
110- // timeouts rethrow so the stage can degrade like the rest of capture.
11193 let waitedOutLoad = false ;
11294 while ( remaining ( ) > 0 ) {
11395 let timer : ReturnType < typeof setTimeout > | undefined ;
@@ -131,7 +113,5 @@ export async function waitForPageReady(
131113 }
132114 }
133115
134- // A document we had to wait out keeps fetching once parsed — settle those
135- // requests too, inside the same deadline.
136116 if ( waitedOutLoad && remaining ( ) > 0 ) await idle ( ) ;
137117}
0 commit comments