The 1am switchover: every test passed, but Claude couldn't connect

EngineeringBunMCPCIHono

Syahmi RafsanjaniCo-founder, CTO

The rewrite took nine days. The switchover took about 10 minutes. Then the one bug showed up on a runtime our tests never ran on.

At 1:18 in the morning I stopped our old order system and took the last backup. By about 1:27, Flair v2 was live and taking orders.

Nine days earlier there was no Flair v2. Claude agents had built it from our spec, across 424 GitHub issues and 507 pull requests, and every test was green.

At 1:30 I connected Claude to the new server. I signed in, then signed in again, and got the same message both times:

Your account was authorized, but Flair returned an error when connecting. You can try again, or check that the server is working.

Our MCP code had changed in the rewrite, but it’s fairly straightforward, and I trusted it. Then Opus traced it to a bug that only showed up when Bun ran Hono and the MCP SDK together. I hadn’t expected that.

Why there was no maintenance page

Most switchovers start with a “we’ll be back soon” page and a rollback plan. We planned ours without either, on purpose.

Every outside system we depend on can catch up on its own. CHIP and Zernio redeliver any webhook we miss. Our delivery reconciler looks GoGet bookings up by reference, so it finds anything booked during the gap. Webhook ids copied from the old app stop anything being processed twice, and checkouts that were open at the switch come across as pending.

What makes that work inside Flair is pg-boss. It’s a job queue that lives in Postgres: each job is a row in our own database, so there’s no Redis or separate queue server to run, back up, or move at 1am.

Every webhook takes the same path. Flair checks that it’s genuine, then saves the event once under its own id and queues a pg-boss job in one transaction. Only then does it answer 200. A separate jobs process picks the job up, runs it, and retries if it fails.

A webhook becomes a job. Nothing is answered until it's safely saved.

So while the old app was stopped, every webhook sent to it failed and was sent again later. And when one arrives twice, its saved id means it’s processed once.

That’s what reliable means here: nothing a customer paid for or sent us can be lost or counted twice. And it came free, with no extra service to run.

The old app stays untouched for 30 days, until 11 December, as a last resort.

So the switch itself was quiet: stop the old app, back it up, copy the data across, check that orders flow. It took about 10 minutes, 5 of them the copy.

Green CI, broken production

Our MCP server is how we use Flair from the Claude app: quoting, creating orders, sending confirmation links. After the switch, sign-in worked, but every real request came back with a 400. The server couldn’t read the request body.

Nothing in our test suite had caught it, because nothing in our test suite ran the way production runs.

Production runs on Bun. Our server tests ran on Node.

Under Bun, Hono’s body-limit middleware touches the request body while checking its size. That’s enough that when the MCP SDK later clones the request to read the body itself, the clone comes back empty. On Node the same code works, which is why every test passed.

Why the body was empty on Bun, and not on Node.

The fix was small: read the body once, then hand the SDK a fresh request.

mcp/route.ts · simplified
// Read the body once, then give the MCP SDK a fresh request.
const body = await c.req.text()
const request = new Request(c.req.raw, { body })
return mcpHandler(request)

Test on the runtime you deploy

The fix took one pull request. The real fix took a second one: every test now runs under bun --bun vitest, and Node is gone from CI. While we were there, release CI started running only the tests a change affects, so a merge doesn’t wait on the whole suite. We’d had a fast, green suite on the wrong runtime, and it took a real client at 1am to show us.

The lesson

If production runs on Bun, your tests run on Bun.

What I’d tell anyone planning a switchover

  • Make every outside system able to catch up. Then you don’t need a maintenance page, because nothing is lost while you switch.
  • Keep the old system, untouched, for a while. Not as a rollback plan, just as somewhere to look things up.
  • Run your tests on the exact runtime you deploy. Same engine, same version.
  • Try the real clients right after the switch. Our tests were green; a real app was the first thing that wasn’t.

The switchover went smoothly. It was the only bug that broke a real client: I found it at 1:30, the fix was merged at 1:43, and by 2:05 every test ran on Bun. With Claude connected again, the rest of this series is about what Flair v2 does now, starting with how we close WhatsApp sales from Claude.

Syahmi RafsanjaniCo-founder, CTO

Planning a switchover of your own? I'm happy to talk it through.

Book a free callSystem review · build work · fractional CTO
Syahmi RafsanjaniCo-founder, CTO