Rollback Strategies for Safe OTA Updates
Learn rollback patterns for React Native OTA updates. Automatic crash detection, instant rollback, and production safety strategies.
Introduction
Shipping updates is great. Shipping broken updates is a nightmare. This guide covers rollback strategies to keep your app stable in production.
The Problem
Without proper rollback:
1. Push update with bug
2. Users download update
3. App crashes on launch
4. Users uninstall app
5. 1-star reviews flood in
6. You scramble to fix and redeploy
7. More users affected in the meantime
With automatic rollback:
1. Push update with bug
2. Users download update
3. App detects crash
4. Automatic rollback to previous version (< 3 seconds)
5. Users continue using app normally
6. You get notified and fix at your pace
7. No users permanently affected
SwiftPatch Automatic Rollback
SwiftPatch monitors your app after each update and automatically rolls back if problems are detected.
How It Works
import { SwiftPatch } from 'swiftpatch';
SwiftPatch.init({
deploymentKey: 'YOUR_KEY',
autoRollback: true, // Enable automatic rollback
healthCheckTimeout: 30000, // 30 second monitoring window
});
Detection Criteria
- Crashes: App terminates unexpectedly
- ANRs: App becomes unresponsive
- Exceptions: Unhandled JavaScript errors
- Custom conditions: Your defined health checks
The Rollback Process
Timeline:
0s - Update downloaded and applied
0-30s - Health monitoring period
- App runs normally? ✓ Mark update as stable
- App crashes? → Immediate rollback
30s+ - Update marked stable, monitoring ends
Configuration Options
Basic Configuration
SwiftPatch.init({
autoRollback: true,
});
Advanced Configuration
SwiftPatch.init({
autoRollback: true,
healthCheckTimeout: 60000, // 60 second window
minHealthyLaunches: 3, // Require 3 successful launches
rollbackOnException: true, // Rollback on unhandled exceptions
onRollback: (info) => {
// Custom rollback handler
analytics.track('OTA Rollback', {
version: info.rolledBackVersion,
error: info.error,
});
},
});
Custom Health Checks
SwiftPatch.init({
autoRollback: true,
healthCheck: async () => {
// Custom health validation
const dbConnected = await checkDatabase();
const apiReachable = await checkAPI();
if (!dbConnected || !apiReachable) {
throw new Error('Health check failed');
}
return true;
},
});
Staged Rollouts
Reduce blast radius by rolling out gradually:
# Deploy to 1% of users
swiftpatch release --rollout 1
# After 1 hour, expand to 10%
swiftpatch promote --rollout 10
# After monitoring, go to 100%
swiftpatch promote --rollout 100
Automatic Rollout Expansion
swiftpatch release \
--rollout 1 \
--auto-expand \
--expand-after 1h \
--expand-to 10,50,100
This automatically expands from 1% → 10% → 50% → 100% if no issues are detected.
Manual Rollback
If you need to rollback manually:
# Rollback to previous version
swiftpatch rollback
# Rollback to specific version
swiftpatch rollback --version 1.2.3
Monitoring Rollbacks
Dashboard View
- Rollback rate over time
- Affected users count
- Error details and stack traces
- Version distribution
Alerts
Configure alerts for rollbacks:
# swiftpatch.yaml
alerts:
- type: rollback
threshold: 1 # Alert on any rollback
channels:
- slack:#engineering
- email:team@company.com
Best Practices
1. Always Enable Auto-Rollback in Production
SwiftPatch.init({
autoRollback: process.env.NODE_ENV === 'production',
});
2. Test in Staging First
# Deploy to staging
swiftpatch release --environment staging
# Test manually
# Deploy to production
swiftpatch release --environment production
3. Use Staged Rollouts
Never deploy to 100% immediately. Start with 1-5% and monitor.
4. Monitor Error Rates
SwiftPatch.on('updateApplied', () => {
// Start monitoring error rate
errorRateMonitor.start();
});
5. Have a Rollback Runbook
- How to trigger manual rollback
- Who has permission
- How to verify rollback succeeded
- Communication plan for users
Conclusion
Rollback isn't about preventing bugs—bugs happen. It's about minimizing their impact. With SwiftPatch's automatic rollback, your users stay protected even when things go wrong.
Ready to ship updates faster?
Get started with SwiftPatch for free. No credit card required.
Join WaitlistRelated Articles
Expo EAS Update Pricing: Cost, Bandwidth & What It Really Costs at Scale
Expo EAS Update feels cheap when you're starting out. Then your app grows. Here's how Expo actually bills for EAS Update, why costs grow faster than you expect, and what happens when you're shipping frequent releases to real users.
ComparisonExpo EAS Update Alternative — Best Expo Updates Replacement with Patch Updates
Expo EAS Update works well inside the Expo ecosystem. But as apps scale, teams need patch updates, rollback, internal testing, bare React Native support, and on-premise hosting. Here's how SwiftPatch compares.
GuidePatch Updates: The Modern CodePush Alternative
Microsoft CodePush is deprecated. Learn how to migrate to SwiftPatch, the modern OTA update platform for React Native with 98% smaller patches, automatic rollback, and enterprise security.