I Killed My Electron App Twice to Test Crash Recovery
Description and use
Crash‑recovery testing in an Electron app showed that persisted frames and partially encoded MP4s can be restored, and a duration check uncovered an FFmpeg bug.
Problem
Ensuring an Electron‑based media exporter can recover from an abrupt process termination and finish user work without data loss.
Outcome
The crash‑recovery harness successfully recovered from both capture and encoding interruptions, preserving all three frames and producing a three‑second MP4 with correct codec, pixel format, and duration. A regression test caught a duration overrun bug caused by FFmpeg’s concat demuxer.
Workflow
- 1. Launch Electron app in a separate process group.
- 2. Persist a per‑session manifest (JSON) with output folder, raw‑frame folder, target duration, format, timestamps.
- 3. Capture synthetic PNGs or real screenshots until a checkpoint (e.g., after third PNG).
- 4. Send SIGKILL to the process group to simulate crash.
- 5. Restart Electron app, which scans recovery directory for manifests.
- 6. For each manifest, rebuild missing frames or restart FFmpeg to finish encoding.
- 7. Use ffprobe to verify H.264 codec, yuv420p pixel format, duration within 150 ms of target, unchanged PNG bytes, and that only completed session manifests are cleared.
- 8. Run regression test to cap encoded output at calculated duration using FFmpeg’s -t flag.
- 9. Verify results and clean up stale manifests.
Evidence
I used an Electron recorder as the example below. The mechanics are simple: persist something, kill the process, restart, find the leftovers, rebuild, then inspect the result.
The harness runs two scenarios: Capture interruption – after the third PNG is persisted; Encoding interruption – after the real FFmpeg process starts.
After each kill, a fresh Electron process reads local recovery manifests. The harness rebuilds every discovered session, runs ffprobe on the output and verifies…
The first recovery run failed on a stricter check than "the file exists." The story target was three seconds. ffprobe measured 3.458333 seconds.
- Record date: 2026-10-05T19:41:03.464Z