Skip to content
All writing

My smoke test passed and two screens were 500ing

The deploy said healthy. /health returned 200, /login returned 200, the script printed its green line, and two screens inside the app were throwing 500s to the only person using it.

The shape

The app is a multi-tenant management tool I am building for Autosterea's local-business clients: plain Node http, pg, server rendered HTML, no build step, one VPS, one Postgres database, deployed by a shell script that tars the source up, backs up the running copy, swaps it in, restarts the systemd unit and smoke tests the result. That last step was doing two checks. It now creates a real session, walks nine authenticated routes, and rolls the whole release back on any 5xx. The two bugs it missed would both have been caught by it.

old: smoke test hits /health and /login, both unauthenticated, and calls the deploy good
new: smoke test mints a 2 minute session in Postgres and curls all 9 app screens, any 5xx auto-rolls back

A liveness check is not a test

The first broken screen was /app/bookings/new. A parallel workstream had rewritten the bookings view to query services.party_size, a column that only migration 005 adds, and 005 had never been applied. I merged it and shipped it anyway.

Every check in the deploy passed, because every check in the deploy was outside the login wall. /health asks whether the process is up. /login asks whether the process can render its simplest page to a stranger. Neither one touches a screen a signed-in user actually looks at, which is to say neither one tests the app.

The gate now generates a token, writes its hash into the sessions table with a two minute expiry, and curls all nine app routes with that cookie. Anything at or above 500 gets collected, printed, and used to roll the release back to the timestamped backup and restart the unit. It cleans its own session up on the way out. It is about fifteen lines of shell and it turns "the process started" into "every screen a user can reach still renders."

The second broken screen was subtler and the same root cause. A theme pass replaced the legacy auth stylesheet with rules for a redesigned login page whose view file was never wired, so the markup actually being served had no rules for any of its classes. /login returned a clean 200 the entire time. It was just completely unstyled. A status code cannot tell you a page looks broken, which is a limit worth knowing about the check you are relying on.

Grepping the source is not looking at the screen

Then the owner sent me a screenshot of the sidebar with the avatar, the buttons and the footer text piled on top of each other.

I had added three stacked children to a container that was already display: flex and never changed its direction, so they laid out in a row and overlapped. Every check I had been running was some form of "is this class present in the output," and the class was present in the output. The bug was entirely in what the browser did with it.

So I stopped asserting on strings and started rendering. Two of the three bugs in that pass were only visible in a real viewport: an icon-rail collapse written at max-width: 1099px had been left unscoped, so it was also hiding the nav labels inside the mobile hamburger panel, and on a phone the menu was a column of unlabelled icons. The same unscoped rule hid the signed-in user's name and role in that panel too.

Getting a truthful mobile screenshot took its own detour. Headless Chrome on Windows silently clamps --window-size to a 500 pixel minimum, so my "390 pixel" screenshot was actually 500 pixels wide and showed a horizontal overflow that did not exist. I had spent time chasing a layout bug that was an artifact of my own measuring tool. Rendering the page inside a 390 pixel iframe gave a real phone viewport and the phantom overflow disappeared.

The inline style that beats every media query

The mobile pass turned up a pattern I will now go looking for. The Reports screen was forcing its three panel desktop grid onto a phone, and the Calendar was pinning a 1,036 pixel wide seven column template onto a 390 pixel screen. Both had responsive overrides written for them. Both overrides were correct. Neither one ever applied, because the template was set as an inline style attribute on the element, and an inline style outranks every media query in the stylesheet.

The fix in both cases was to stop emitting the value inline and let the stylesheet own it: modifier classes on Reports, and a CSS custom property the stylesheet can narrow on Calendar. A media query cannot beat an inline style, so the layout has to be expressed as something the stylesheet is allowed to win.

There was one more guard worth keeping. All of this theme work grew the tenant stylesheet from 28.7KB to 40.5KB, and every other tenant on the app shares the same codebase and must not move a pixel. So there is an assertion that the default theme's stylesheet is exactly 3,333 bytes, checked on every run. It is a crude test and it is the right one: it does not care what I changed, only that the tenant I was not working on came out byte for byte identical.

What I learned

A health check that never logs in has not tested your app. /health and /login were both 200 while a signed-in screen was 500ing on a column that did not exist. The check has to hold a session and touch the routes users touch, or it is only telling you the process started. Minting a throwaway session inside the smoke test costs a few lines of shell and is the difference between a gate and a formality.

Asserting that the markup is right is not the same as seeing the page. The overlapping sidebar had every class it was supposed to have. The bug was a flex direction, which no grep will ever find and one screenshot finds instantly. And when you do start rendering, check your renderer: a headless browser that quietly clamps the viewport to 500 pixels will invent layout bugs for you to chase.

In a shared codebase, prove that the thing you did not touch did not change. One app, several tenants, one stylesheet dispatcher. The proof that this week's redesign was safe for everyone else is not a review, it is an assertion that the other theme is still exactly 3,333 bytes. Cheap, exact, and it fails loudly the first time a "small shared tweak" leaks across a tenant boundary.

If your deploy pipeline is telling you a release is healthy when it is not, that gap is the kind of thing Autosterea fixes.

First published on ravikantdewangan.com.

Tell us what eats your week.

A free 20-minute call. We'll show you what we would take off your plate.

Book a call