Auto-update
Ende.autoUpdate() polls a release server for
new versions, downloads binary-diff patches, applies them to the runtime dylib,
and stages the result for the next launch. If the new version fails to start,
the runtime rolls back to the previous version automatically. Updates ship as small bsdiff
patches instead of full binary downloads, with rollback baked into the launcher.
Platform support
Auto-update works on macOS and Linux only. On Windows,
Ende.autoUpdate() logs that auto-update isn't supported on Windows yet and
does nothing else.
Ende 2026.11.10
On Windows, Ende.autoUpdate() says that auto-update isn't supported. Earlier
releases logged that ende.json had no version.
Prerequisites
Two pieces of configuration are required, and a third is strongly recommended:
- A
versionin yourende.json:{ "version": "1.4.0" } - A
desktop.release.baseUrlin yourende.json:{ "desktop": { "release": { "baseUrl": "https://releases.example.com/my-app" } } } - A
desktop.release.publicKeyin yourende.json(Ende NEXT_RELEASE+), the key your update manifests are signed with. See Signed manifests.
All three are baked into the compiled binary. When publicKey is set, version
must be ChronVer (YYYY.MM.DD[.N]) or semver, and ende desktop fails the
build otherwise. When baseUrl is set without publicKey, ende desktop warns
that the app will install unsigned updates (Ende NEXT_RELEASE+).
The version is exposed at runtime as
Ende.desktopVersion:
console.log(Ende.desktopVersion); // "1.4.0", or null if no version was set
If Ende.desktopVersion is null,
Ende.autoUpdate() is a no-op: the runtime
warns once and returns.
Ende.desktopVersion and Ende.autoUpdate() exist only in apps built with
ende desktop. Under ende run both are undefined, and calling
Ende.autoUpdate() throws a TypeError. To run the same entry point with
ende run during development, guard the call:
if (typeof Ende.autoUpdate === "function") {
Ende.autoUpdate({ interval: 60 * 60 * 1000 });
}
Calling autoUpdate()
Ende.autoUpdate({
url: "https://releases.example.com/my-app",
interval: 60 * 60 * 1000, // hourly
onUpdateReady(version) {
console.log("Update", version, "ready; will apply on next launch");
},
onRollback(reason) {
console.warn("Previous launch failed; rolled back:", reason);
}
});
Or pass a URL string for a single one-shot check on startup:
Ende.autoUpdate("https://releases.example.com/my-app");
| Option | Type | Notes |
|---|---|---|
url |
string |
Required if no desktop.release.baseUrl is set in ende.json. With a key built in, any URL other than baseUrl throws (Ende NEXT_RELEASE+). |
interval |
number (milliseconds) |
Poll interval. If omitted, only a single check is performed. |
onUpdateReady |
(version: string) => void |
Called once a patch is applied and staged for next launch. |
onRollback |
(reason: string) => void |
Called shortly after this call if the previous launch failed. |
publicKey |
string |
Deprecated (Ende NEXT_RELEASE+): set desktop.release.publicKey instead. See Signed manifests. |
Manifest format
The runtime fetches <url>/latest.json and parses it as JSON. Each patch entry
is an object carrying the patch filename, the patch's SHA-256 hash, and the
SHA-256 hash of the library the patch produces:
{
"version": "1.5.0",
"patches": {
"1.4.0": { "name": "patch-1.4.0-to-1.5.0.bin", "sha256": "<64-hex-chars>", "targetSha256": "<64-hex-chars>" },
"1.4.1": { "name": "patch-1.4.1-to-1.5.0.bin", "sha256": "<64-hex-chars>", "targetSha256": "<64-hex-chars>" }
}
}
| Field | Meaning |
|---|---|
version |
The latest available version. Compared with Ende.desktopVersion. |
patches |
Map of from-version → { name, sha256, targetSha256 }. name is the patch filename relative to the manifest's URL; sha256 is the lowercase hex SHA-256 of the patch bytes; targetSha256 is the lowercase hex SHA-256 of the new version's runtime library, the file the patch produces. |
Both hashes are required. The runtime refuses a patch whose bytes don't hash
to sha256, so a tampered or truncated download is never applied. It then
applies the patch to the installed library and refuses the result unless it
hashes to targetSha256, so a patch made from a different build is never
staged. An entry without targetSha256 is skipped with an error in the log, and
nothing is downloaded.
Ende 2026.11.10
targetSha256 is required. Apps built with this release ignore manifest
entries written without it.
Old versions you no longer want to support can be omitted from patches. Users
on those versions log a "no patch available for X" message and stay on their
current version.
The update URL must be https://: the runtime refuses to poll a plaintext
endpoint.
Signed manifests
For tamper protection beyond TLS, sign the manifest with an Ed25519 key and set
the public key as desktop.release.publicKey in ende.json: standard padded
base64 of the 32-byte key, next to baseUrl, which it requires.
{
"version": "2026.12.02",
"desktop": {
"release": {
"baseUrl": "https://releases.example.com/my-app",
"publicKey": "<base64-encoded 32-byte Ed25519 public key>"
}
}
}
The key is built into the app. The manifest must then be an envelope:
{
"signed": "{\"version\":\"1.5.0\",\"patches\":{ … }}",
"signature": "<base64 Ed25519 signature over the `signed` string>"
}
The runtime verifies signature over the exact bytes of the signed string
with the built-in key, then reads the patch hashes from signed as the trusted
manifest. To avoid depending on a canonical-JSON implementation, the real
manifest is embedded verbatim as the signed string and only its contents are
trusted. An unsigned manifest, or one whose signature doesn't verify, is
rejected.
With a key built in, an update is staged only if its manifest is signed with
that key and offers a newer version than the running app (see
Versions), whatever the app's code passes to
Ende.autoUpdate(). The signature is checked in
the runtime's Rust code, not in JavaScript, so code in the app can't skip it.
Ende.autoUpdate() also refuses a url or publicKey different from the ones
in ende.json: it throws. Passing the same key only logs a deprecation warning,
so call it without one:
Ende.autoUpdate({ interval: 60 * 60 * 1000 });
Ende NEXT_RELEASE
desktop.release.publicKey is new, and the publicKey option of
Ende.autoUpdate() is deprecated. Without a key in ende.json, the option
works as before: when it's set, the manifest must be signed with it. It only
protects against a tampered manifest, though, not against code in the app
that calls autoUpdate with its own URL and key.
Versions
The runtime compares the manifest's version with the running app's. Both are
ordered when both are ChronVer (YYYY.MM.DD[.N], by date) or both are semver
(by precedence):
- A manifest for the same version does nothing.
- A manifest for an older version is refused, so a replayed old manifest can't downgrade the app (Ende NEXT_RELEASE+).
- With a key built in, a manifest whose version the app can't order against its own is refused too: one in the other scheme, or in neither. Without a key, an update the app can't order is applied as before.
A version is ChronVer only with a two-digit month and day: 2026.12.1 isn't
ChronVer and is read as semver. Keep one spelling for every release of an app.
If a release switches spellings, apps built with a key can't order its versions
against theirs and refuse every update from it, so those users are stranded.
Update flow
- Fetch manifest.
GET <url>/latest.json. On a non-2xx response, the check silently returns and waits for the next interval. Redirects are refused, and the runtime fetches with its own internalfetch, not the global one, which the app's code can replace (Ende NEXT_RELEASE+). - Compare versions. If
manifest.version === Ende.desktopVersion, nothing to do. Older versions are refused (see Versions). - Look up a patch.
manifest.patches[Ende.desktopVersion]→{ name, sha256, targetSha256 }. - Download the patch.
GET <url>/<name>. The whole patch is buffered into memory; for typical bsdiff outputs (a few MB) this is fine. - Verify and apply. When updates must be signed, the runtime verifies the
manifest's signature in Rust, after the download and before anything is
staged, and takes the patch hashes from the verified manifest (Ende
NEXT_RELEASE+). It checks the downloaded bytes against the manifest's
sha256and refuses to continue on a mismatch, then applies the binary diff to the app's runtime dylib using theqbsdiffcrate. The patched bytes must hash totargetSha256. A library that was rolled back before (see below) isn't staged again, even though its patch has been downloaded. - Stage the result. Write the patched dylib as
<dylib>.updatenext to the original. The running dylib is left untouched. - Fire
onUpdateReady.
The running dylib is untouched until the next launch. On the next launch, before any of the app's code runs, the runtime swaps the staged update into place and restarts the app into the new version right away, in the same launch:
- On Linux, and for a loose binary on macOS, the process re-executes itself with the same arguments and environment.
- A macOS
.appbundle is restarted through LaunchServices (open), after the old process has exited. The new run gets the environment of a Finder or Dock launch, not the old process's environment, standard streams or working directory, and a shell that started the old process sees it exit with code 0.
Rollback on failed launch
The runtime keeps its update state in files next to the runtime dylib:
<dylib>.update (a staged update), <dylib>.backup (the previous dylib),
<dylib>.update-trial (the new version's first launch has started),
<dylib>.update-ok (the new version started successfully), and
<dylib>.update-rejected (the hash of a library that was rolled back).
- If
<dylib>.updateexists, the runtime keeps the current dylib as<dylib>.backup, swaps the staged update into place, and restarts into it. - The new version's first launch is its trial. It succeeds once the main module
has finished evaluating (top-level
awaitincluded) and the event loop has run once more, without an uncaught error or unhandled rejection in that time. Exiting with code 0 before then also counts as success. On success the runtime writes<dylib>.update-ok, and the next launch removes the backup. - If a launch finds a trial that never succeeded, the update failed to start:
the runtime restores
<dylib>.backup, records the failed library's hash in<dylib>.update-rejected, and restarts into the previous version. ItsEnde.autoUpdate()call then firesonRollbackwith the reason. The rejected library is never staged again, even if the release server keeps offering it; the record is cleared once a later update is confirmed. - A second copy of the app started while the trial launch is still running uses the new version without confirming or rolling it back.
This makes broken updates self-healing. Users do not need to know anything happened beyond seeing the same version they had before. Only failures during startup are rolled back: an update that starts and crashes later in its trial launch stays installed. The rollback itself runs inside the new library's startup code, so an update whose library can't be loaded at all is never rolled back.
Ende 2026.11.10
The update is applied by a restart in the same launch, the trial ends once the main module has run, and rolled-back updates aren't staged again. In earlier releases a staged update took effect on the launch after the swap.
Generating patches
A patch is a bsdiff of the app's runtime dylib between two releases, the file
the updater patches, which lives inside your built app. qbsdiff reads the
bsdiff 4.x format, so the classic bsdiff CLI produces compatible output:
bsdiff old-dylib new-dylib patch-1.4.0-to-1.5.0.bin
shasum -a 256 patch-1.4.0-to-1.5.0.bin # the sha256 for the manifest entry
shasum -a 256 new-dylib # the targetSha256
Then add the patch's name, sha256 and targetSha256 to latest.json and
upload both the patch and the manifest to your release server.
For shipping multiple architectures (macOS arm64, Linux arm64 and x86_64), generate patches per-architecture. Either serve the right manifest based on user-agent, or include all patches under architecture-specific keys and pick on the client:
// release/darwin-aarch64/latest.json
{
"version": "1.5.0",
"patches": {
"1.4.0": { "name": "patch-1.4.0-to-1.5.0.bin", "sha256": "<64-hex-chars>", "targetSha256": "<64-hex-chars>" }
}
}
const arch = Ende.build.os + "-" + Ende.build.arch; // "darwin-aarch64"
Ende.autoUpdate({
url: "https://releases.example.com/" + arch,
interval: 60 * 60 * 1000
});
With a key built in, the URL can't be chosen at runtime: build each
architecture with its own desktop.release.baseUrl instead (Ende
NEXT_RELEASE+).
Where updates can apply
Updates rewrite the app's own library file in place, so they only apply where
the user running the app can write to its installed files: for example a .app
bundle the user can write to (in /Applications too, if the user may change
it) or an app directory the user unpacked. For a read-only or system-owned
install, such as a .deb / .rpm package installed under /usr, the write
fails, the failure is logged, and the update is skipped. Distribute updates for
those through the system package manager instead.
An AppImage is mounted read-only when it runs, so it can't update itself. An
AppImage built with --compress
runs the app it extracted to $XDG_DATA_HOME (usually ~/.local/share), and
that copy can update.
Best practices
- Sign your manifests. TLS plus the required per-patch
sha256already stop a tampered patch from being applied, but anyone able to serve from your URL could still push a validly-hashed malicious patch. Sign the manifest with an Ed25519 key and setdesktop.release.publicKey(see Signed manifests). Keep the private key off the release host. - Use one key per app. With a key shared across apps, one app's signed patch can be served to another.
- Rotate a key with a signed update. Ship the new key in an update signed with the old one. If that update fails its trial launch, the app rolls back to the old build and its old key (see Rollback on failed launch), so keep signing with the old key until the new build is confirmed.
- Test patches against a real install. A patch that applies cleanly but produces a non-bootable binary triggers rollback, but only after a failed launch, so your users see a brief startup failure once. Run the patched binary in CI before publishing the manifest.
- Choose a sensible interval. Hourly is fine for most apps. Polling more often than every few minutes is wasteful for both you and your users.
- Handle
onRollback. A rollback is a signal that a recent release was broken on at least one machine. Log it to your telemetry so you notice broken releases quickly.