# Running the 320px overflow check after every deploy

> The overflow scan was a manual E2E test. I made it run in the background after every successful deploy and email on overflow. It hit page.route hangs, sendBeacon ignoring the UA, and a log-skip spoof.

- Date: 2026-11-30
- Topics: DevOps, Debugging
- Chinese original: https://kbs0830.com/blog/overflow-check-after-every-deploy

[The previous post](/en/blog/overflow-320-every-page) turned "no page may scroll sideways at 320px" into an E2E test, and ended with one limitation: this site's E2E has been manually triggered since 11-29 and does not run on push. This time I hooked it into an automatic flow.

## Why not just put it in GitHub Actions

Deploys and E2E both run on the same desktop at home, and GitHub Actions has only this one self-hosted runner, which can do one thing at a time. If E2E went into the push flow, the next deploy would have to queue behind it, which is why it became manual on 11-29.

So it now **runs in the background after a successful deploy**. After the deploy script prints "Deploy succeeded", it hands the check to the background and exits, and the runner is free right away. The script that warms the Cloudflare cache after a deploy already works this way.

What the background check does:

- It first waits 90 seconds, so the site's boot warm-up and the cache warm-up finish before it starts, and it does not fight them.
- CPU priority is set to "below normal", which Playwright and the browser it opens inherit.
- It hits the live site on its local port directly, without going through Cloudflare.
- If a new deploy starts midway, it stops itself, and the check runs again after that new deploy finishes.
- If any page overflows, it sends an email listing which page and which element pushed it out. When a later check passes, it sends a "recovered" email.

That night several jobs were pushing code at the same time, the live site was deploying every 1 to 2 minutes, and the check was aborted 6 times in a row. So during consecutive deploys, only the check after the last deploy runs to the end.

On the test site, one full round takes 81 seconds. I deliberately put a 400px-wide `div` on `/privacy`, and it was caught in 75 seconds:

```text
/privacy 80px extra: div#overflow-probe (right edge 400px "")
```

## Problem 1: after adding page.route, all three parts hung for 10 minutes

When running against the live site, some side effects are unwanted. For example, the `/ask` page asks the server to load the AI model into the GPU the moment it opens, and with dozens of deploys a day that would load it dozens of times. I first blocked those requests in the test with Playwright's `page.route`.

The result: all three parts hung at `page.goto`, never finished loading the page, until the 10-minute cap. The version without `page.route` finished in 1.4 to 1.8 minutes on the same test site.

This site has Speculation Rules on: when the mouse rests on a link for about 200ms, Chrome loads that whole page in the background. The test scrolls all the way to the footer, and the mouse may happen to rest on some link. If the next URL to open is exactly that page, Chrome swaps in the prerendered page directly. My guess: requests sent by that prerendered page are not caught by `page.route`, and so they hang forever. I did not dig further to prove the mechanism, but removing `page.route` ended the hangs.

The unwanted side effects are now handled on the server side: when the warm-up API sees a User-Agent carrying this site's own tool marker, it skips the work.

## Problem 2: requests sent when leaving the page did not get the UA

So that the live site can tell "this is my own check", the test browser's User-Agent has an extra marker appended, and when the server sees it, it does not write the request into the request log. Otherwise one round would add thousands of lines and the log would fill up within hours.

After adding it, 400 lines still ended up in the log, almost all from two APIs: Web Vitals and the online count. Both are sent with `navigator.sendBeacon` when the page is left. The `userAgent` in the Playwright config has no effect on that kind of request.

I added `--user-agent` to the Chromium launch arguments as well. With both layers set, the same round wrote 0 lines to the log.

## Problem 3: deciding whether to log from the UA alone

Before pushing, the automatic security review stopped me: the User-Agent is whatever the visitor sends, so if only the UA is checked, anyone can set their UA to that marker and make their own requests disappear from the log.

So I added two more conditions, and the log line is skipped only when all three hold:

- The connection comes from the local machine (`127.0.0.1` or `::1`).
- There is no Cloudflare `cf-connecting-ip` header. This machine's outside traffic comes through the Cloudflare Tunnel, which also connects from the local machine, but it always carries this header.
- The UA has the marker.

I tried four kinds of requests with curl: local plus the marker returning 200 is not logged; one carrying `cf-connecting-ip` is logged as usual; a 404 is logged as usual; an ordinary UA is logged as usual.

## Result

- After every successful deploy, a 320px check runs against the live site in the background without taking the runner.
- Overflow triggers an email with the page and the element that pushed it out. If the check itself fails to finish (timeout, browser will not start), that is a separate email, so it is not confused with "the layout has a problem".
- A limitation: this catches problems after they are live. When adding a page or changing a layout, I still need to run it myself before going live.

---

Author: PINGWEI LI (李秉威, Li Ping-Wei)
Original page: https://kbs0830.com/en/blog/overflow-check-after-every-deploy
