Repository navigation
The crash that killed your app now comes with the response that caused it. Persistence has been reworked underneath to make that possible — if you already have it on, the only thing you need to know is that previously archived logs are discarded once (see Upgrading).
💥 The response behind the crash survives it
Persistence already existed, but a crash still lost the one entry worth having. The archive is rewritten whole, so saves were debounced by two seconds and flushed on backgrounding — and a foreground crash arrives before either, taking the response that caused it with it.
Logs are now written ahead of that, one line per entry as it's captured, so a log reaches disk in about a millisecond. On the next launch the inspector opens with a Previous session crashed banner, a View button that jumps straight to the exchange blamed for it, a red CRASH badge on that row, and a Crash section carrying the call stack directly above the response body:
Crash
SIGTRAP
Likely cause Swift runtime trap — a force unwrap of nil, an out-of-range
index, an overflow or an explicit fatalError. Check the
response below against what the decoding code expects.
Call Stack …
Response Body
{"data":{"outlet":[{"id":"not-a-number","name":"Warung Kopi"}]}}
The crash block is prepended to that entry's raw log export too, so one shared file carries the payload and the stack together.
It's on by default once persistence is on:
ApiLogKitConfig.persistence.captureCrashes = false // to opt out🪤 Swift traps are caught, not just NSException
Most Swift crashes — a force unwrap of nil, an out-of-range index, fatalError — never raise an NSException. They trap, and arrive as a POSIX signal. Those are exactly the crashes a bad payload produces, so they're handled alongside NSException, and a signal report carries a plain-language note about what the trap usually means.
Inside a signal handler only async-signal-safe functions may be called, so the handler allocates nothing: a pre-opened descriptor, a pre-rendered header, hand-formatted integers and backtrace_symbols_fd. Then it restores the previous handler and re-raises — your crash reporter is unaffected, whichever order the two install in.
⏳ In-flight requests are kept
A request that was still out when the app died used to be dropped at save time, on the grounds that a restored pending entry can never complete. That was right about the spinner and wrong about the entry: it's the strongest evidence there is, and it leaves no other trace. Those entries are persisted now and come back badged No response, with a banner on the detail screen instead of a spinner that would never stop.
🎯 Blame is scoped to the run that crashed
Suspects are everything in flight plus the newest finished entry — and only from the run that actually crashed. Without that, an app that launched, sat idle and crashed would pin the blame on the previous run's last response, confidently and wrongly.
Upgrading
- Previously archived logs are discarded once. Entries gained an id and a lifecycle, so the archive format is now version 2 and a version 1 archive is dropped on read rather than migrated. Debug logs are disposable; nothing else is affected.
LogSectiongained a.crashcase. If you switch exhaustively over it in your own code, that switch needs a new branch. Everything else is additive:ApiLoggainedcrash,PersistenceOptionsgainedcaptureCrashes, andLogEventType/ApiLogStatebecame raw-valued andCodablewith their cases unchanged.
Known limit
An entry reaches disk one queue hop after it's captured, so a crash synchronous with the logging call can still outrun it. The gap is sub-millisecond and decoding crashes happen well after it, but it isn't the hard guarantee the Android library gets from blocking in its handler — closing it entirely would mean an fsync on every log write.