fix(mobile): Persist crash diagnostics before runtime fatals - #4033
fix(mobile): Persist crash diagnostics before runtime fatals#4033juliusmarminge wants to merge 5 commits into
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour. 📝 WalkthroughWalkthroughThe mobile app adds crash logging. It installs the global error handler before the app module graph evaluates, persists fatal errors, reports recent records at startup, and limits stored records to 20. ChangesMobile crash logging
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change installs early mobile crash logging to persist and report fatal-error diagnostics without altering the existing error-handler chain. No current merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant AppEntry as Mobile app entry
participant CrashLogger as installCrashLogger
participant FileSystem as Document directory
participant ReactNative as React Native global error handler
AppEntry->>CrashLogger: initialize before app modules
CrashLogger->>ReactNative: install fatal-error handler
ReactNative->>CrashLogger: deliver fatal error
CrashLogger->>FileSystem: write timestamped JSON record
CrashLogger->>FileSystem: read and prune crash records
CrashLogger->>CrashLogger: report up to three recent records
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…oads Co-authored-by: codex <codex@users.noreply.github.com>
ApprovabilityVerdict: Needs human review This PR introduces new crash logging infrastructure that installs a global error handler before the app module graph loads. While defensively implemented, changes to fatal error handling at this level warrant human review. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 959a39b. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Squashed replay of pingdotgg#4033 pr3910-crash-capture, one of Julius's open pingdotgg#3910 split PRs, as a post-CTM layer. Replaces the retired ios-integration merge, so this line keeps main pinned to exactly what CTM contains. Applied as the PR's net diff against its own main base; no conflicts against CTM.
Squashed replay of pingdotgg#4033 pr3910-crash-capture, one of Julius's open pingdotgg#3910 split PRs, as a post-CTM layer. Replaces the retired ios-integration merge, so this line keeps main pinned to exactly what CTM contains. Applied as the PR's net diff against its own main base; no conflicts against CTM.
Squashed replay of pingdotgg#4033 pr3910-crash-capture, one of Julius's open pingdotgg#3910 split PRs, as a post-CTM layer. Replaces the retired ios-integration merge, so this line keeps main pinned to exactly what CTM contains. Applied as the PR's net diff against its own main base; no conflicts against CTM.

Extracted from #3910.
Adds early JS crash capture, disk-backed breadcrumbs, and a synchronous native write path so release-runtime failures leave recoverable diagnostics before React Native terminates. It also records outbox activity as crash context.
Validation inherited from #3910:
vp checkand mobile native lint passed before the split. The full typecheck is currently blocked in this workspace by unavailable mobile dependencies (expo-blur,expo-quick-actions, and@tabler/icons-react-native).Note
Persist crash diagnostics to disk before runtime fatals in the mobile app
installCrashLoggerthat intercepts fatal errors, writes a JSON crash record to the device'scrash-logsdirectory, then delegates to the previous handler.crash-<epoch>-<seq>.jsonfor stable lexicographic ordering; on next launch, the most recent 3 are logged to the console and files beyond 20 are pruned.installCrashLog.tsis imported at the top ofindex.tsas a side-effect so the handler registers before any other app modules load.ErrorUtilsis unavailable the installer does nothing.Macroscope summarized 65fbd78.
Note
Medium Risk
Fatal-error handling performs synchronous document-directory file I/O before the prior global handler runs, which can add latency on the crash path and must not interfere with existing crash reporting.
Overview
Adds early fatal JS crash capture so release-runtime failures leave recoverable diagnostics before React Native tears down.
A side-effect import at the top of
index.tsrunsinstallCrashLogger()before the rest of the app loads. The logger chains React Native’s globalErrorUtilshandler: on fatal errors it synchronously writes a JSON record (message, name, stack, timestamp) undercrash-logsin the document directory, then calls the previous handler. Persistence is wrapped so logging failures never hide the original crash.On the next launch, a deferred
setTimeout(0)pass (no file I/O during install) warns the three newest prior crash files to the console and prunes older logs beyond a cap of 20.Reviewed by Cursor Bugbot for commit 6209d13. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit