@@ -1472,6 +1472,32 @@ export async function executeDiskCaptureWithAdaptiveRetry(options: {
14721472 const remainingCount = countFrameRanges ( remaining ) ;
14731473 const madeProgress = captureAttemptMadeProgress ( frameCount , remainingCount ) ;
14741474
1475+ // A browser that times out starting up or loading its page before any frame exists had too many pages
1476+ // opening at once: retry with half the workers, down to one. Other zero-progress errors fail below.
1477+ // A lone worker gets one retry: here for Network.enable, as the transient retry below for a page load.
1478+ if (
1479+ options . allowRetry &&
1480+ ! madeProgress &&
1481+ ( currentWorkers > 1 ||
1482+ ( initializationRetriesUsed === 0 && failure . kind === "protocol_timeout" ) ) &&
1483+ / \b N e t w o r k \. e n a b l e t i m e d o u t | N a v i g a t i o n t i m e o u t o f \d + m s e x c e e d e d / i. test ( failure . message )
1484+ ) {
1485+ initializationRetriesUsed ++ ;
1486+ const nextWorkers = getNextRetryWorkerCount ( currentWorkers ) ;
1487+ options . log . warn (
1488+ "[Render] Browser initialization timed out; retrying with fewer workers." ,
1489+ {
1490+ fromWorkers : currentWorkers ,
1491+ toWorkers : nextWorkers ,
1492+ error : failure . message ,
1493+ } ,
1494+ ) ;
1495+ currentWorkers = nextWorkers ;
1496+ missingRanges = remaining ;
1497+ attempt ++ ;
1498+ continue ;
1499+ }
1500+
14751501 // Single bounded retry for a transient browser death (`Target closed` /
14761502 // `Page crashed` / `Session closed`): the tab died mid-capture, not the
14771503 // composition. Unlike the worker-halving retry below, this keeps the same
@@ -1500,32 +1526,6 @@ export async function executeDiskCaptureWithAdaptiveRetry(options: {
15001526 continue ;
15011527 }
15021528
1503- // CDP initialization can time out before any frame exists. Give that
1504- // specific startup failure one fresh attempt with less concurrency;
1505- // arbitrary zero-progress authoring/capture errors still fail below.
1506- if (
1507- options . allowRetry &&
1508- ! madeProgress &&
1509- initializationRetriesUsed === 0 &&
1510- failure . kind === "protocol_timeout" &&
1511- / \b N e t w o r k \. e n a b l e t i m e d o u t / i. test ( failure . message )
1512- ) {
1513- initializationRetriesUsed ++ ;
1514- const nextWorkers = getNextRetryWorkerCount ( currentWorkers ) ;
1515- options . log . warn (
1516- "[Render] Browser initialization timed out; retrying once with fresh sessions." ,
1517- {
1518- fromWorkers : currentWorkers ,
1519- toWorkers : nextWorkers ,
1520- error : failure . message ,
1521- } ,
1522- ) ;
1523- currentWorkers = nextWorkers ;
1524- missingRanges = remaining ;
1525- attempt ++ ;
1526- continue ;
1527- }
1528-
15291529 if ( ! madeProgress ) {
15301530 options . log . warn (
15311531 "[Render] Capture attempt made no forward progress; composition is likely structurally broken, not retrying." ,
0 commit comments