Skip to content

fix(mobile): Persist crash diagnostics before runtime fatals#4033

Open
juliusmarminge wants to merge 4 commits into
pingdotgg:mainfrom
juliusmarminge:codex/pr3910-crash-capture
Open

fix(mobile): Persist crash diagnostics before runtime fatals#4033
juliusmarminge wants to merge 4 commits into
pingdotgg:mainfrom
juliusmarminge:codex/pr3910-crash-capture

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jul 16, 2026

Copy link
Copy Markdown
Member

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 check and 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

  • Adds a global JS error handler via installCrashLogger that intercepts fatal errors, writes a JSON crash record to the device's crash-logs directory, then delegates to the previous handler.
  • Crash files are named crash-<epoch>-<seq>.json for stable lexicographic ordering; on next launch, the most recent 3 are logged to the console and files beyond 20 are pruned.
  • installCrashLog.ts is imported at the top of index.ts as a side-effect so the handler registers before any other app modules load.
  • Risk: file I/O failures during a crash are silently swallowed; if ErrorUtils is unavailable the installer does nothing.

Macroscope summarized 6209d13.


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.ts runs installCrashLogger() before the rest of the app loads. The logger chains React Native’s global ErrorUtils handler: on fatal errors it synchronously writes a JSON record (message, name, stack, timestamp) under crash-logs in 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.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c8ee91ad-e4b1-44d7-9fb7-185332a6bea2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 16, 2026
@juliusmarminge
juliusmarminge marked this pull request as ready for review July 16, 2026 09:25
…oads

Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp

macroscopeapp Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

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.

Comment thread apps/mobile/src/lib/crashLog.ts
Comment thread apps/mobile/src/lib/crashLog.ts
Co-authored-by: codex <codex@users.noreply.github.com>
Comment thread apps/mobile/src/lib/crashLog.ts Outdated
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant