fix(browser): pageError.location needs valid defaults, not just optional chaining (#918 follow-up) #927

Merged
bot-reviewer merged 1 commit from fix/918-pageerror-validator-default into main 2026-05-31 20:15:40 +00:00

1 commit

Author SHA1 Message Date
7141648d35 fix(browser): pageError.location needs valid defaults, not just optional chaining (#918 follow-up)
#918 patched pageError.location.{url,lineNumber,columnNumber} -> optional
chaining (?.) but that is INSUFFICIENT. With location undefined, ?.url yields
undefined, and playwright 1.60.0's protocol validator (tString) requires a
string -> 'ValidationError: location.url: expected string, got undefined' ->
still crashes the driver connection -> tradein-browser 500 + browser relaunch.
The #918 fix merely traded TypeError for ValidationError; run_34 'verify'
grepped for the TypeError signature and missed the ValidationError.

Proven on the local stack (2026-05-31): once the proxy IP gets flagged, avito
serves an anti-bot challenge page whose JS throws a locationless uncaught error
on EVERY fetch -> ValidationError crash-storm -> 0 lots across all anchors.

Fix: provide valid defaults so the validator passes — url -> '', line/column -> 0.
The pageError event is then delivered without crashing; the browser returns the
challenge HTML, the pipeline detects the firewall and rotates the IP gracefully
instead of crash-looping. Verified in-container: node --check OK, 2 sites guarded.

Refs #883, #901, #915, #916
2026-05-31 23:13:19 +03:00