StartupCrashWatchdog class

Self-healing startup watchdog that detects crash loops on downloaded OTA patches and automatically falls back to the embedded base binary.

If an app crashes consecutively maxCrashThreshold times during the initial healthyThresholdDuration launch window, the watchdog triggers onRollbackTriggered to purge the faulty patch.

Example:

final watchdog = StartupCrashWatchdog(
  maxCrashThreshold: 2,
  healthyThresholdDuration: const Duration(seconds: 5),
  onRollbackTriggered: (patchId, reason) {
    print('Rolling back faulty patch $patchId: $reason');
  },
);
watchdog.recordAppLaunch('patch_12');

Constructors

StartupCrashWatchdog({WatchdogStorage? storage, int maxCrashThreshold = 2, Duration healthyThresholdDuration = const Duration(seconds: 5), void onRollbackTriggered(String faultyPatchId, String reason)?})
Creates a StartupCrashWatchdog.

Properties

hashCode int
The hash code for this object.
no setterinherited
healthyThresholdDuration Duration
Duration after launch after which startup is considered healthy.
final
isHealthy bool
Whether current startup has stabilized and reached healthy state.
no setter
maxCrashThreshold int
Maximum permitted startup crashes before initiating automatic rollback.
final
onRollbackTriggered ↔ void Function(String faultyPatchId, String reason)?
Callback triggered when self-healing rollback occurs.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
storage WatchdogStorage
Persistence storage delegate for crash metrics.
final

Methods

dispose() → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordAppLaunch(String? patchId) → void
Starts monitoring application startup for the given patchId.
recordStartupCrash() → void
Manually or automatically record an unhandled startup crash.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited