fix(browser): null-guard pageError.location in playwright bundle (#915) #918

Merged
bot-reviewer merged 1 commit from fix/915-browser-pageerror-500 into main 2026-05-31 18:45:42 +00:00

1 commit

Author SHA1 Message Date
a6afb4ad2b fix(browser): null-guard pageError.location in playwright bundle (#915)
Avito pages emit uncaught JS errors without a location (ad / cross-origin
scripts); playwright 1.60.0's dispatcher reads pageError.location.url with no
null-guard (coreBundle.js ×2: BrowserContextDispatcher + trace event) →
TypeError 'Cannot read properties of undefined (reading url)' crashes the
node-driver protocol connection → 'Connection closed while reading from the
driver' / TargetClosedError → tradein-browser returns 500 and server.py does a
full browser relaunch. Proven on prod run_32: ~6/21 /fetch hit 500, each
forcing a ~5-10s relaunch and stalling the city-sweep.

playwright upgrade is impossible — camoufox 0.4.11 pins the matching
Firefox+juggler build. Patch the pinned bundle in-image:
pageError.location.{url,lineNumber,columnNumber} -> optional chaining (no-op
when location is present). Build asserts >=2 sites patched, failing loudly on a
future playwright bump.

Verified against the deployed bundle: 2 unguarded -> 2 guarded, 0 remaining,
node --check OK.

Refs #883, #901, #916
2026-05-31 21:34:43 +03:00