↓ Skip to main content

Video 9 min

Replacing My Self-Hosted Expo Update Server with Codemagic Patch

I moved a real Expo app, native projects and all, from expo-updates to Codemagic Patch: the local stack, the migration, a bug I caused and fixed over the air, and what rollback looks like when a release actually crashes.

Narrated in English Subtitles: English, 日本語, 한국어, Tiếng Việt, 简体中文

Transcript

I published an update I knew would crash. The app downloaded it, restarted, and died to the home screen. I opened it again. It crashed again. The docs said a bundle that crashes gets rolled back.

So why wasn't it? With the server I'd built myself, there was no rollback on the device at all. A bad update would crash every launch until I noticed.

To explain, I have to start with that server. In February I wrote about building my own Expo update server. Until this move, it had carried every fix for maru, the community app I run, for about a dollar a month. But I own every piece of it. Planning this move, I found my publish script had printed "Sent zero push notifications" after every production publish, since the day I wrote it.

Nobody noticed, least of all me. That's roughly what running your own thing turns into. So when Codemagic asked me to try Patch, their open-source, self-hostable take on CodePush, I insisted on a real app, not a demo. They paid me for the migration and the write-up, and reviewed it for factual accuracy only.

Patch is a server you run yourself, and an SDK in your app. The app never asks the server about updates. It just fetches files from storage. Each release names the exact binary it's for, and the CLI won't publish onto native code that doesn't match. My server had a version string and a lot of hoping.

My trial on the laptop came with demo data: canary releases, and success and failure counts for each. My old dashboard had an "active" checkbox. Then I pointed it at maru. In three seconds, its doctor check found a real problem. It thought the iOS app was version two point oh point oh.

The app is two point five point one. The CLI had read a stale plist from maru's widget extension, whose folder sorts first. The stale file was my bug. But every iOS release would target a version no phone runs. Nothing would error.

Updates would just never arrive. My publish script now passes the version explicitly, and Codemagic has since fixed the bug. In the app, the SDK throws if its native module is missing, and maru also ships for the web. So I load it lazily, and never on web. And by default, mandatory updates reload the app wherever the user is.

I changed it to apply the next time the app comes back from the background, because losing a half-written post is a worse bug than most fixes are good.

Natively, the guide's prebuild step wiped files and hand edits from my committed native projects. Not Patch's fault, but the guide didn't warn you. It does now. So I made the few changes by hand, with keys from the build environment. An empty key quietly disables updates, so store builds now refuse to build without one.

My first release changed the onboarding headline. Publishing took thirty seconds. The catch: an update must be built with the binary's environment, or it talks to the wrong backend. I relaunched. The whole check was two requests to storage.

Then a download, and the app offered a restart. Then the dashboard showed one simulator as two installs. My code confirmed the bundle, then called sync, which confirms it too. Both counted, permanently. My fix shipped over the air as a binary diff of five hundred and forty-three kilobytes.

That's about seven percent of the full bundle.

Rollback was what I cared about most. So I released a version three that throws before the first render, so it can never confirm it's healthy. That was the crash from the start. The source explains it: the SDK allows three unconfirmed launches, because one can just mean iOS killed a healthy process. The fourth launch came back up on version two, without anyone touching the server.

But a bad release costs each user three crashed launches. That's the case for Staging first, and a small Production rollout second. Stopping it for everyone else took one command. The previous release comes back as a new one, and the crashing one stays in the list. The honest record.

Android had two surprises, neither of them Patch's. Then the same story: an update applied, and a crash rolled back after three launches.

Beyond that, rollouts are deterministic, so the same phone stays in or out. Each deployment allows one partial rollout at a time. And promotion reuses the exact package you tested. The fingerprint guard refused releases after harmless edits, even a changed comment in the app config. Overriding was right then.

Usually, the honest answer is a version bump and a store build. Code signing worked on both platforms. The catch: the public key must be in the first binary you ship, because an update can't add it. So, how hard is it? Trying it is easy.

Integrating it is moderate, mostly because of my own project's edges. Day to day, it's good. Hosting it is the bigger commitment. For a team already running servers, it's a quiet afternoon. For a team on EAS to avoid servers, it's the real cost of switching.

I wrote up every snag for Codemagic. By late September, most were fixed. Production was still a plan: the server on Fly.io and Tigris, next to maru, not yet a supported path, with one machine always running. Its key step: check the keys really made it into the built app.

In October came the first native upgrade, to Expo SDK fifty-eight. This time I ran that check. iOS had its Patch settings. Android had none. Android's new build tooling shrinks resources much harder.

The SDK reads its settings by name, which the shrinker can't see, so it stripped them as unused. Missing means empty, and empty means "no updates". Nothing would have failed. Android phones on the new version would just never get an update. The fix is one small file telling the shrinker to keep them.

The same check caught a launch crash inside Expo's own modules, with no update to roll back. It protects you from a bad update, not from a bad binary. So my checklist grew: dump the Patch settings from the built apps, compare the keys with the build profile, and launch the release build itself. If you pay for EAS Update because building a server looked like too much work, Patch is a real answer. You run a server, not code you maintain.

You get staged rollouts, real install numbers, signing and rollback, none of which I'd built. It costs a new binary, a server to maintain, and by default three crashed launches per user when a release goes bad. It's young. I hit bugs, and made one of my own. None stopped the migration, and all of it was visible, which is more than I can say for my old setup.

The full post, with every command, config and link, is on jared.lynskey.co.nz.

More videos

Claude Code Worktrees: Running Parallel Agents Without Collisions

Cloudflare 520, nginx 499 and Postgres Stalls: Keeping Webhooks Alive

pytest-testmon: Run Only the Tests Affected by Your Code Change

How to Debug an iOS App in Xcode: Breakpoints, LLDB, Instruments and the Simulator