Skip to content

Recognize crash mid OAuth2 token fetch as a network error - #2857

Open
bengotow wants to merge 1 commit into
masterfrom
claude/awesome-ritchie-8z72fb
Open

bengotow wants to merge 1 commit into
masterfrom
claude/awesome-ritchie-8z72fb

Conversation

@bengotow

@bengotow bengotow commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Fixes https://foundry-376-llc.sentry.io/issues/MAILSPRING-CLIENT-DH

What I observed

MAILSPRING-CLIENT-DH is "An unknown error has occurred mailsync: 3765269347" — 116 users impacted, 240 events, all on Windows. Every single sampled event (25/25) has the identical shape:

Waiting for Account JSON:

Waiting for Identity JSON:
info: Identity created at <ts> - using ID Schema 1
info: Fetching XOAuth2 access token (gmail) for <accountId>

...with mailsync exiting with code 3765269347, which is exactly 0xE06D7363 — the well-known Microsoft Visual C++ runtime SEH code that signals an uncaught C++ exception. This always happens in test mode, which is used by finalizeAndValidateAccount() (app/internal_packages/onboarding/lib/onboarding-helpers.ts) right after the user finishes the OAuth flow for a new Gmail/Outlook account.

So the pattern is: mailsync logs that it's about to fetch an OAuth2 access token, and then the process dies with a native C++ exception before it can log anything else — most likely because Windows security software that intercepts TLS (corporate antivirus, proxies, etc.) causes the HTTPS client to throw mid-request instead of failing gracefully.

MailsyncProcess._buildCrashError already has a heuristic for this exact class of problem (TLS interception during test mode), but it only fires when mailsync manages to log a {"offline":true} JSON marker before crashing. Here the crash happens too early for that marker to ever be written, so the heuristic never fires, and:

  • Users see an unhelpful "unknown error ... 3765269347" message instead of "Connection Error - check your internet connection."
  • oauth-signin-page.tsx's _onError only skips reporting to Sentry when err.isNetworkError (or isUserError) is set, so this crash — which isn't a fixable Mailspring bug — keeps flooding error tracking.

The actual native crash lives in the C++ sync engine (a separate repo), so it can't be root-caused or fixed from this codebase.

The fix

Widen _buildCrashError in app/src/mailsync-process.ts to also recognize this fingerprint: test mode, exit code 0xE06D7363, and a log tail showing the crash happened while fetching an OAuth2 token. When matched, it's classified the same way as the existing {"offline":true} case — the user gets the friendly, localized connection-error message, and the error is no longer reported to Sentry as an unexplained crash.

Added app/spec/mailsync-process-spec.ts covering both the existing offline-marker case and the new OAuth2-crash fingerprint (including that it's scoped to test mode and doesn't misclassify unrelated crashes that happen to share the same exit code).

Test plan

  • Added unit tests for _buildCrashError covering both network-failure signatures and the negative cases (wrong mode, unrelated crash with the same exit code)
  • Could not run the full Jasmine suite in this environment (no node_modules installed); verified the change compiles cleanly via an isolated tsc check

🤖 Generated with Claude Code

https://claude.ai/code/session_01BfBhpanbqfLKX7csCsArzN


Generated by Claude Code

Windows security software that intercepts TLS (corporate antivirus,
proxies) can make mailsync's HTTPS client throw an uncaught C++
exception while fetching an OAuth2 access token, crashing the process
with SEH code 0xE06D7363 (the MSVC runtime's "C++ exception" signature)
before it can log the usual {"offline":true} marker. This bypassed the
existing network-failure detection in _buildCrashError, so every
occurrence surfaced to users as an unhelpful "unknown error" message
and was reported to Sentry as an unactionable crash (MAILSPRING-CLIENT-DH,
~100 Windows users hitting this exact exit code while linking a new
Gmail/Outlook account).

Detect this specific crash fingerprint - the known SEH code plus a log
tail showing the process died fetching an OAuth2 token - and classify
it the same as the existing offline-marker case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BfBhpanbqfLKX7csCsArzN
@indent-staging

indent-staging Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Important

Indent Zero has shut down and no longer reviews pull requests.
To get this pull request reviewed by Indent instead:

  1. Sign up for Indent
  2. Install Indent on your repositories
  3. Turn on code review
  4. Comment @indent on this pull request

Step 4 is only needed for pull requests that were already open when you switched. After that, Indent reviews new pull requests on its own.

To stop this notice, turn PR reviews off in Indent Zero.

@indent

indent Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
PR Summary

Recognizes a specific Windows crash as a network error so affected users get a helpful message and the crash stops flooding Sentry. Sentry issue MAILSPRING-CLIENT-DH shows ~116 Windows users hitting exit code 3765269 (0xE06D7363, the MSVC signature for an uncaught C++ exception) right after mailsync logs it's about to fetch an OAuth2 token during new-account validation — most likely TLS-intercepting security software making the HTTPS client throw mid-request. The existing test-mode network-error heuristic only fired on an "offline":true log marker, which is never written when the crash happens this early.

  • MailsyncProcess._buildCrashError now also flags isNetworkError when the exit code is 0xE06D7363 and the log contains Fetching XOAuth2 access token, additive to and preserving the existing offline-marker path, still scoped to mode === 'test'.
  • As a result, oauth-signin-page._onError shows the localized connection-error message and skips reporting the crash to Sentry.
  • Adds a mailsync-process-spec.ts unit spec covering the new signature plus guardrails: offline-marker case, mode scoping, matching exit code with an unrelated log, and signal-terminated crashes.

Issues

No issues found.

CI Checks

All CI checks passed on 6db1dd6.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants