r/learnprogramming • • 9d ago

My browser agent works on localhost, never on the server

every order on our dashboard says "we value your privacy". the agent reads each freight carrier's tracking page into it (no APIs), and on localhost it worked every time, team demo included.

shipped it in a container, not one clean run since. chrome needed a pile of system libs first. then the privacy thing: locally it used my chrome profile, where I'd dismissed every consent banner months ago, and the server starts clean every run. making it click accept first fixed one carrier and broke the next, each puts that button somewhere else.

I keep telling the team it's almost fixed. how do you test what a fresh browser on a server sees?

10 Upvotes

17 comments sorted by

4

u/The_God_was_Here 9d ago

Your laptop was never testing a first visit. That profile had already answered every banner, so every local run skipped the part the server hits. Run the local checks with a throwaway profile each time and you see roughly what the server sees.

1

u/TaviaWisteria 9d ago

do you run that in ci or only before a deploy? asking before I tell the team it's almost fixed again.

7

u/orb-effect 9d ago

the eu cookie law doing more QA than our whole team

5

u/LavenderBunnyPie 9d ago

Worth sorting the carriers before fixing any more banners. A tracking page that only shows a status line doesn't need a full browser for the agent to read it. How are people splitting that off, browserbase's fetch for the plain status pages?

1

u/Vegetable_Lunch_2047 9d ago

Ours were supplier stock pages. We requested each one raw and looked for the stock number in the response, and most were plain server rendered HTML. Only a couple needed real clicks, so only those got a browser.

1

u/martinez-k60 5d ago

One clean split is a per-carrier adapter behind a shared getStatus interface; test each HTML parser against a sanitized fixture. That isolates markup changes and makes regressions reproducible without relying on live tracking pages.

5

u/glossyvibe7 9d ago

We got past the missing libs and it still never ends. Every base image bump breaks the browser somehow, missing fonts one week, shared memory too small the next, and only ever on the server. I think I've spent more time keeping a browser alive in that image than on the agent it's for lol.

3

u/Rhea-Dreamdaisy 3d ago

Tbf --disable-dev-shm-usage or bumping shm_size fixes it then it's fonts or something else the next week lol gave up on keeping chrome in out own image and moved the browser to browserbase, the container just runs the agent.

1

u/miss_strawberryxx 9d ago

and always on the box where you cant just open devtools and look

5

u/cloudbambi_flux 6d ago

run it locally with a fresh broswer context every time, no profile, and you'll see exactly what the server sees. for the banners, hardcoding the accept button breaks per site like you found, so i use stagehand's act ( "accept cookies" ) which finds it wherever each site puts it. we also run on browserbase and save the session after the first run, so the banners are already discmissed after that, same as you local chrome

1

u/JGhostThing 9d ago

So you shipped a version of the code you never really tested? You just assumed it would work?

1

u/bizvibe8 8d ago

Put it in CI, not just a pre-deploy checklist. Give the browser a new temporary profile for every run, start from a clean cookie and storage state, and assert both the expected page content and that the agent either handles or explicitly stops on consent UI. Keep one smoke test against the real clean container image too, since profile cleanup alone will not catch missing Chrome libraries or fonts.