refactor(web): use max for the settle budget

This commit is contained in:
pj committed 2026-08-13 01:36:39 +05:30
1 parent b7d3b1b7cb
commit 83285f0c30
1 file changed
+1 -4
+1 -4
View File
@@ -548,10 +548,7 @@ func (d *Driver) WaitForIdle(ctx context.Context, timeout time.Duration) error {
defer cancel() defer cancel()
// Leave the caller's deadline some room: returning late by our own doing // Leave the caller's deadline some room: returning late by our own doing
// would surface as a context cancellation instead of a settled page. // would surface as a context cancellation instead of a settled page.
budget := timeout - 100*time.Millisecond budget := max(timeout-100*time.Millisecond, domQuietPeriod)
if budget < domQuietPeriod {
budget = domQuietPeriod
}
script := fmt.Sprintf(settleScript, domQuietPeriod.Milliseconds(), budget.Milliseconds()) script := fmt.Sprintf(settleScript, domQuietPeriod.Milliseconds(), budget.Milliseconds())
return chromedp.Run(runCtx, return chromedp.Run(runCtx,
chromedp.WaitReady("body", chromedp.ByQuery), chromedp.WaitReady("body", chromedp.ByQuery),