When an update goes wrong: how Endcord rolls itself back
Automatic updates are great until one breaks. Endcord keeps the last working version and puts it back by itself.
Automatic updates have a nasty failure mode. If a release stops Endcord from starting, it also stops Endcord from downloading the fix. With everyone on automatic updates, one bad build would strand every user at the same moment. So an update in Endcord has to prove itself, or it's undone.
Before anything changes: the signature
Each release comes with a manifest that lists the SHA-256 of every file, signed with a key that isn't stored in the repository or on any server. Endcord checks the signature first, then downloads every file and checks each hash. Only when all of them match does it touch the installed files. A stolen GitHub or website account can't ship an update, because it can't sign one. You can run the same check yourself in the Trust Center.
The swap, with a safety net
previous folder.update-state.json, records that a swap is in progress, with the hash of every kept file.Two things can go wrong, and both are covered:
- The power goes off mid-swap. At the next start, the journal still says "swapping", so the old files go back. You never end up with half of one release and half of another.
- The new version doesn't start. If three Discord page loads pass without the confirmation, the previous version is restored and the page reloads. The broken release is remembered and not installed again; the next release is offered as normal.
Why three page loads
We count page loads rather than program starts. Opening a second Discord window, or starting while offline, doesn't count against a release, so a good update isn't rolled back by accident. Three gives a release room for a slow first start, while a truly broken one costs you three page loads instead of a broken client.
Before restoring, Endcord checks the kept files against the hashes it wrote down. If something changed them in the meantime, it refuses to restore them rather than run files it can't vouch for. When a rollback does happen, Endcord tells you once with a notification, and the Security card in settings shows it.
What it can't catch
The confirmation arrives when Endcord starts, so a release that breaks something later in a session isn't caught by this. And because this code lives in the part of Endcord that loads first, it can't save a release where that part itself fails to load. For that case, the installer's loader falls back to plain Discord, so Discord still opens.
The reasoning behind all of this is written up in the decision records: signed updates and update rollback.
