Skip to content
THE OTA MANUALCore architecture
Verifiedv0.1.0 ↗

Rollback & persisted data limits ​

ota-nativescript guarantees offline recovery of application code and updatable assets. Understanding where those guarantees stop — especially around launch timing and local persisted data — is essential before operating OTA in production.

Jolt Recovery Lab

Offline Crash Rollback & Store Upgrade

STAGED
Active bundle: ota-vue-v2 (confirmed) attempts: 0 / 1

ota-vue-crash is validly signed and staged for next cold launch

Ed25519 and SHA-256 passed — yet the bundle throws on top-level import before updates.markReady() can ever run.

// state.json
{
  "confirmedReleaseId": "ota-vue-v2",
  "stagedReleaseId": "ota-vue-crash",
  "pendingLaunch": null,
  "failedReleaseIds": []
}

How the crash recovery loop works ​

Before V8 starts on a cold launch, the native bootstrapper reads state.json:

  1. Store binary upgrade check: if the installed targetBuild or runtimeContract differs from state.json, native code resets all OTA pointers (confirmedReleaseId, stagedReleaseId, pendingLaunch, failedReleaseIds), deletes obsolete releases/, and boots the new store-shipped embedded bundle immediately.
  2. Unconfirmed candidate check: if pendingLaunch is still set from the previous launch, markReady() never completed.
    • If attempts >= maxLaunchAttempts (default 1), native code appends releaseId to failedReleaseIds, writes lastRecovery (failedReleaseId, recoveredTo, recoveredReleaseId, attempts, recoveredAt), clears pendingLaunch, and boots confirmedReleaseId (or falls back to the immutable embedded bundle).
    • If attempts < maxLaunchAttempts, native code increments attempts, persists state.json, and retries once more.
  3. Staged activation: if stagedReleaseId exists and its entry file is valid on disk, native code promotes it to pendingLaunch (attempts = 1) and boots it.
  4. Confirmed boot / fallback: otherwise native code boots confirmedReleaseId if present and valid on disk, or falls back to the embedded bundle.

Neither updates.markReady() nor rollback requires network connectivity.

Explicit limits ​

1. User force-close during startup looks identical to an unconfirmed boot ​

Native pre-boot code only knows whether updates.markReady() ran before the process exited. If a user opens the app and immediately swipes it away before the first screen finishes mounting, the next launch sees an unconfirmed pendingLaunch.

  • Keep updates.markReady() early — right after your root screen mounts — and never wait on network calls, authentication flows or remote feature flags.
  • maxLaunchAttempts defaults to 1 for fast recovery; teams with slower cold starts can raise it to 2 in ota.config.json to tolerate an accidental early swipe-close.

2. Code rollback does NOT revert local persisted data ​

Persisted data rule

Rolling back JavaScript cannot undo SQLite schema migrations, modified ApplicationSettings keys, local cache files or server-side state mutations already written by the failed release.

Follow the expand-and-contract rule for every OTA release:

  • Additive schema changes only: adding nullable columns or new tables stays readable if the app rolls back to confirmedReleaseId or the embedded bundle.
  • Never drop or rename SQLite columns or preference keys inside an OTA update. Save breaking local-storage migrations for a store binary release where the embedded fallback already understands the new schema.
  • Guard new preference formats defensively: parse persisted JSON with fallbacks so older JS code tolerates unknown fields written by a newer release.

3. Mid-session swaps are intentionally unsupported ​

ota-nativescript never hot-swaps JavaScript modules inside a running V8 isolate. Swapping code mid-session risks dangling native delegates, navigation stacks and inconsistent state. Updates always stage quietly in the background and activate cleanly on the next cold process start.