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.
Offline Crash Rollback & Store Upgrade
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:
- Store binary upgrade check: if the installed
targetBuildorruntimeContractdiffers fromstate.json, native code resets all OTA pointers (confirmedReleaseId,stagedReleaseId,pendingLaunch,failedReleaseIds), deletes obsoletereleases/, and boots the new store-shipped embedded bundle immediately. - Unconfirmed candidate check: if
pendingLaunchis still set from the previous launch,markReady()never completed.- If
attempts >= maxLaunchAttempts(default1), native code appendsreleaseIdtofailedReleaseIds, writeslastRecovery(failedReleaseId,recoveredTo,recoveredReleaseId,attempts,recoveredAt), clearspendingLaunch, and bootsconfirmedReleaseId(or falls back to the immutable embedded bundle). - If
attempts < maxLaunchAttempts, native code incrementsattempts, persistsstate.json, and retries once more.
- If
- Staged activation: if
stagedReleaseIdexists and its entry file is valid on disk, native code promotes it topendingLaunch(attempts = 1) and boots it. - Confirmed boot / fallback: otherwise native code boots
confirmedReleaseIdif 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. maxLaunchAttemptsdefaults to1for fast recovery; teams with slower cold starts can raise it to2inota.config.jsonto 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
confirmedReleaseIdor 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.