Engineering

A Three-Pass Code Audit in 14 PRs

Part five of building oo-workers in public: a deliberate code-quality pass shipped as 14 small PRs, the hardening it added, and one big file split.

ObserveOne Team
2 min read

In this series

Building oo-workers in public

  1. 1.How We Built a Self-Hosted Monitoring Engine
  2. 2.Eight Monitor Types From One Engine
  3. 3.Building the Dashboard Without a Framework
  4. 4.A Portable Backup Format, Not pg_dump
  5. 5.A Three-Pass Code Audit in 14 PRs
  6. 6.Killing the 5-Second Poll
  7. 7.Cutting the Docker Image to 1.4 GB
  8. 8.Tests That Spin Real Databases
  9. 9.The Alert That Never Fired

After shipping fast (the engine, eight monitor types, a dashboard, and backups), we stopped for a deliberate code-quality pass. Three passes, actually, shipped as 14 small PRs merged the same day.

Hardening, not just style#

Import atomicity. You can seed a self-hosted instance from hosted ObserveOne: run obs export from the ObserveOne CLI to produce a snapshot, then import the bundle into oo-workers. That bulk write runs inside a single transaction, so a crash partway through rolls back cleanly rather than leaving a half-populated instance.

Heartbeat endpoint. A heartbeat ping arrives at a public token URL, so the endpoint is hardened accordingly: pings are debounced, valid and invalid tokens get the same response, and only POST records a ping, so a GET link preview does nothing.

List query bounds. Incident, status-page, and API-key listings cap at 500 rows, which bounds memory on long-lived instances.

Scheduler stall surfacing. On a sustained database or Redis outage, a counter tracks consecutive failed ticks and raises a loud stall warning, with a recovery log on the first healthy tick, so an outage announces itself instead of going unnoticed.

The big split#

server.ts had grown to 1769 lines. The audit split it into a 150-line orchestrator plus 14 per-resource route files, handlers moved verbatim. Settings, backup, dialogs, and incidents got the same treatment. No behavior changed, the files just got small enough to hold in your head.

Why schedule a pass#

Shipping fast accrues debt you stop seeing. A scheduled pass is permission to harden the paths nobody would file a ticket for. Doing it as 14 small PRs kept every change reviewable and revertable, instead of one giant cleanup PR no one can read.

Ready for AI-Powered Testing?

ObserveOne monitors your selectors 24/7 and automatically heals them when websites change. Never deal with broken tests again.

Start Free Trial