fix(browser): local camoufox + HTTP wrapper, drop broken playwright WS server (#905) #909
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#909
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/905-browser-http-wrapper"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The
tradein-browsercontainer from #907 crash-loops in prod. Root-caused by running the built image: camoufox 0.4.11'slaunch_serverspawns a NodelaunchServer.jsthatrequire()splaywright/driver/package/lib/browserServerImpl.js— a file that no longer exists in any playwright 1.45–1.60 (verified by probing each). Socamoufox.server.launch_serveris fundamentally incompatible with current playwright →MODULE_NOT_FOUND→RuntimeError: Server process terminated unexpectedly, restart loop.The deploy that shipped #907/#908 left
tradein-browsercrash-looping — harmless to prod (browser is dormant,scraper_fetch_mode=curl_cffi), but the container never comes up.Fix — don't use the playwright protocol between containers
Verified that local
AsyncCamoufoxworks fine in the image (launches Firefox, drives a page). So the browser container now runs camoufox locally and exposes plain HTTP; the backend talks to it over httpx — no fragile playwright WS server.browser/server.py— aiohttp service holding a localAsyncCamoufox(headless, os/locale/geoip/humanize, proxy fromSCRAPER_PROXY_URL).POST /fetch {url}→ new_page → goto → content → close →{html};GET /health. Page-recycle every N + crash-recovery (relaunch + 1 retry), serialized viaasyncio.Lock.browser/Dockerfile—+aiohttp(the #908 camoufox-fetch-as-root block is untouched).BrowserFetcher—playwright.firefox.connect→httpx.post(browser_http_endpoint + "/fetch"), one retry on transport/HTTP error; all playwright imports dropped.browser_ws_endpoint→browser_http_endpoint(http://tradein-browser:3000).Verified by a REAL local image build + run
camoufox fetchpasses (#908 fix intact).Restarting (1)).GET /health→ 200{"status":"ok"}.POST /fetch {"url":"https://example.com"}→ 500Page.goto: NS_ERROR_UNKNOWN_HOST— i.e. the request reached the server, camoufox launched Firefox and began navigation, failing only on DNS (no egress in the local build env). This proves the full HTTP→camoufox→Firefox chain; a real page fetch validates on prod (network + proxy).Risk
Dormant —
scraper_fetch_modestayscurl_cffi, no runtime behavior change. Replaces the crash-looping container sobuild-browser/deploy go green andtradein-browseractually comes up. Refs #905, #883, #884The playwright WS-server path (camoufox.server.launch_server) is incompatible with playwright >=1.45: camoufox 0.4.11's launchServer.js requires playwright/driver/package/lib/browserServerImpl.js, which no longer exists in any playwright 1.45-1.60 → tradein-browser crash-looped with MODULE_NOT_FOUND ('Server process terminated unexpectedly'). Verified by running the built image. Pivot (no playwright protocol between containers): - browser/server.py: aiohttp service holding a local AsyncCamoufox (headless, os/locale/geoip/humanize, proxy from SCRAPER_PROXY_URL). POST /fetch {url} → new_page/goto/content/close → {html}; GET /health. Page-recycle every N + crash-recovery (relaunch + 1 retry), serialized via asyncio.Lock. - browser/Dockerfile: +aiohttp (camoufox fetch-as-root/#908 block untouched). - backend BrowserFetcher: playwright.connect → httpx POST to the browser service (one retry on transport/HTTP error). All playwright imports dropped. - config: browser_ws_endpoint → browser_http_endpoint (http://tradein-browser:3000). Verified by a REAL local image build + run: image builds, container stays Up (Restarts=0, no crash-loop), GET /health=200, POST /fetch launches camoufox and drives Firefox (only NS_ERROR_UNKNOWN_HOST = no DNS egress in the local build env, proving the full HTTP→camoufox→Firefox chain; real fetch validates on prod with network+proxy). 7 unit tests + ruff clean. Dormant: scraper_fetch_mode stays curl_cffi. Refs #905, #883, #884