fix(core-rpc): demote timeout unhandled-rejections + classify in client (#REACT-15+)
Summary
- Promote local 30 s
AbortControllerRPC timeout from bareError→CoreRpcError(kind='timeout')so callers, Sentry filters, and future telemetry can branch on a stable kind instead of regex-matching messages. - Add
'timeout'precedence toclassifyRpcErrorso the local-ceiling shape wins over the broadertransportarm (mirrors PR #2063 loopback-vs-transport). - Stop the OPENHUMAN-REACT-15/11/10/12/Z/Y unhandled-rejection family at the three settings panels (
TeamPanel,TeamInvitesPanel,TeamMembersPanel) and twoCoreStateProviderwrite paths (updateLocalState,storeSessionToken). - Last-line-of-defense
beforeSendfilter inanalytics.tsdrops any futureCoreRpcError(kind='timeout')that slips past a missing.catch().
Problem
Eight Sentry issues (~18 events, 18 unique users) all triggered via auto.browser.global_handlers.onunhandledrejection:
| ID | Surface | Method |
|---|---|---|
| OPENHUMAN-REACT-15 / 11 | TeamPanel.tsx:31 → CoreStateProvider:listTeams |
openhuman.team_list_teams |
| OPENHUMAN-REACT-10 | TeamMembersPanel:44 |
openhuman.team_list_members |
| OPENHUMAN-REACT-12 | TeamInvitesPanel:37 |
openhuman.team_list_invites |
| OPENHUMAN-REACT-13 / 14 | Backend chain | GET /teams[/members] 504 / connect timeout |
| OPENHUMAN-REACT-Z / Y | Post-write refresh | openhuman.app_state_snapshot |
All hit the 30 s CORE_RPC_TIMEOUT_MS ceiling (REACT-Z/Y arrived as bare Error: because coreRpcClient.ts:381 threw new Error(...) not CoreRpcError). Each call site fired the RPC as void promise(...) or void promise.finally(...) inside a useEffect, so the rejection bubbled to window.onunhandledrejection → Sentry capture.
Sister to PR #2063 (Rust-side loopback classifier) — same family of "transient infra noise the user already retries past" promoted out of the error surface.
Solution
Layer A — Classifier (coreRpcClient.ts)
- Add
'timeout'toCoreRpcErrorKind. classifyRpcErrornow checks/timed out after \d+ms/iBEFORE the generictransportarm.- AbortController throw site (line 381) throws
CoreRpcError(msg, 'timeout')instead of a bareError— kills the REACT-Z/Y bare-Error:shape.
Layer B — Call-site .catch() (TeamPanel, TeamInvitesPanel, TeamMembersPanel, CoreStateProvider)
- Each panel's mount-effect
void refresh*(...)is replaced with a.catch(err => log(...))that demotes to acore-rpc:errorbreadcrumb. CoreStateProvider.updateLocalStateandstoreSessionTokennow.catch()their follow-uprefresh()— the polling loop reconciles withinPOLL_MS, so a transientapp_state_snapshottimeout no longer escapes as an unhandled rejection.
Layer C — Sentry beforeSend filter (analytics.ts)
- Inspects
hint.originalExceptionand drops the event when it is aCoreRpcError(or duck-typed cross-realm equivalent) withkind === 'timeout'. Non-timeout kinds (transport,auth_expired,rate_limited,budget_exceeded,thread_not_found) still surface.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — new logic is covered: classifier precedence + verbatim REACT-15/11/10/12/Z/Y message bodies + REACT-13 transport-stays-transport guard + AbortController throws
CoreRpcError(kind='timeout')+ SentrybeforeSenddrops timeout / preserves non-timeout / cross-realm match.pnpm debug unit coreRpcClient(75/75) +pnpm debug unit analytics(27/27) +pnpm debug unit CoreStateProvider(22/22) all green. - [x] N/A: Coverage matrix updated — behaviour-only change (classifier kind variant + call-site guards); no new feature row in
docs/TEST-COVERAGE-MATRIX.md. - [x] N/A: All affected feature IDs listed in
## Related— no matrix-tracked feature IDs touched; the Sentry IDs are listed below instead. - [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] N/A: Manual smoke checklist updated — no release-cut surfaces touched (
docs/RELEASE-MANUAL-SMOKE.mdcovers UI surface, not classifier internals). - [x] N/A:
Closes #NNNfor a GH issue — this is a Sentry-only PR (mirrors PRs #1719, #1798, #2063). Sentry IDs listed under## Related.
Impact
- Runtime/platform: Desktop (Tauri) and web — pure frontend change inside
app/src/services/+app/src/providers/+ three settings panels. No native shell, no Rust core change. - Performance: One extra regex test per RPC classification (negligible). One extra
instanceof+ duck-type check per Sentry event (negligible). - Security/PII: None. New log lines route through the existing
sanitizeErrorhelper. ThebeforeSendfilter narrows what is sent, never broadens. - Migration / compat:
CoreRpcErrorKindadds a variant; consumers that switch on it must handle the new arm — none in this repo do today (all consumers use string equality on specific known kinds). No breaking export shape change. - Telemetry: Expect REACT-15/11/10/12/Z/Y event counts to drop to ~0 within one release cycle; REACT-13/14 (backend-side
client error (Connect)) still surface astransport— those are real backend issues, not local noise.
Related
Closes OPENHUMAN-REACT-15 Closes OPENHUMAN-REACT-11 Closes OPENHUMAN-REACT-10 Closes OPENHUMAN-REACT-12 Closes OPENHUMAN-REACT-13 Closes OPENHUMAN-REACT-14 Closes OPENHUMAN-REACT-Z Closes OPENHUMAN-REACT-Y
Sister PR: #2063 (Rust-side loopback classifier — same family, Rust core surface).
- Closes: (Sentry IDs above — no linked GitHub issue)
- Follow-up PR(s)/TODOs: Optional hardening of other
await callCoreRpc(...)consumers (coreCommandClient,coreHealthMonitor,webviewAccountService,memorySyncService,notificationService,chatService,meetCallService,walletApi,daemonHealthService,backendUrl) if their Sentry IDs surface — deliberately out of scope here.
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A — Sentry-only triage (no Linear ticket)
- URL: N/A
Commit & Branch
- Branch:
fix/sentry-corerpc-unhandled-rejection - Commit SHA:
c6c966f7(tip at push time)
Validation Run
- [x]
pnpm --filter openhuman-app format:check - [x]
pnpm typecheck - [x] Focused tests:
pnpm debug unit coreRpcClient(75 pass),pnpm debug unit analytics(27 pass),pnpm debug unit CoreStateProvider(22 pass) - [x] N/A: Rust fmt/check (no Rust changes in this PR)
- [x] N/A: Tauri fmt/check (no Tauri shell changes in this PR)
Validation Blocked
command:N/Aerror:N/Aimpact:N/A — pre-pushpnpm rust:checkinitially failed because thetauri-cef/tauri-plugin-notificationvendored submodules were not yet initialized in this fresh worktree; resolved by runninggit submodule update --init --recursiveand pushed cleanly (no--no-verify).
Behavior Changes
- Intended behavior change: Local AbortController RPC timeouts are now silent at the user-facing layer (logged breadcrumb only) and dropped by Sentry's
beforeSendfilter. Other error kinds (transport,auth_expired, …) are unaffected. - User-visible effect: None for happy-path users. Users who previously hit a 30 s cold-boot timeout on
/settings/teamsno longer see a Sentry-reported crash — the panel quietly waits for the next poll tick / user retry.
Parity Contract
- Legacy behavior preserved: All existing
classifyRpcErrormappings unchanged. All non-timeoutCoreRpcErrorkinds still surface to Sentry. The pre-existingtransportarm still matches every body it matched before (the newtimeoutarm matches a strict subset). - Guard/fallback/dispatch parity checks: Existing "throws CoreRpcError with kind=transport on network error" test still passes; existing "AbortController throws with timeout-shaped message" test extended to also assert the
CoreRpcErrorinstance +kind.
Duplicate / Superseded PR Handling
- Duplicate PR(s): None — FE side of the Sentry-noise family is currently unaddressed.
- Canonical PR: This PR.
- Resolution: N/A
Summary by CodeRabbit
-
Bug Fixes
- Improved error handling and logging for failed team, member, and invite refreshes (swallowing and logging refresh failures to avoid unhandled rejections)
- Enhanced RPC timeout error detection and classification (new timeout kind)
- Prevented unhandled promise rejections during bootstrap and local-state/session updates
- Reduced error monitoring noise by filtering timeout errors from Sentry
-
Tests
- Added regression tests covering RPC timeout classification, Sentry filtering, and unhandled-rejection guards during data loads and provider refreshes
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3efe24b6-9723-4287-b47f-8d8c31fb2c40
📥 Commits
Reviewing files that changed from the base of the PR and between c6c966f7ed995ae5682113a88f16548c275c6dac and d70abbc9fdb3eaf78ab294068cd39af8eedaaaf0.
📒 Files selected for processing (4)
app/src/components/settings/panels/__tests__/TeamInvitesPanel.test.tsxapp/src/components/settings/panels/__tests__/TeamMembersPanel.test.tsxapp/src/components/settings/panels/__tests__/TeamPanel.test.tsxapp/src/providers/__tests__/CoreStateProvider.test.tsx
📝 Walkthrough
Walkthrough
Adds a typed 'timeout' RPC error kind, classifies/throws timeouts from coreRpcClient, filters timeout errors from Sentry beforeSend, and wraps UI/provider refresh calls to catch and log refresh failures; tests verify classification, Sentry filtering, and no unhandled rejections.
Changes
Timeout Error Classification and Filtering
| Layer / File(s) | Summary |
|---|---|
Core RPC timeout classification app/src/services/coreRpcClient.ts |
CoreRpcErrorKind adds 'timeout'. classifyRpcError matches "timed out after 'timeout' before other matches. callCoreRpc throws CoreRpcError(kind: 'timeout') when the AbortController timeout fires. |
Core RPC timeout test coverage app/src/services/__tests__/coreRpcClient.test.ts |
Tests capture rejected CoreRpcError with kind: 'timeout' and assert timeout message formatting; table-driven classifyRpcError tests include timed-out messages and precedence cases. |
Sentry timeout error filtering app/src/services/analytics.ts |
Imports CoreRpcError; adds isCoreRpcTimeoutError(err) (instanceof + duck-typed {name,kind}); updates Sentry beforeSend(event, hint) to drop events when the originalException is a Core RPC timeout. |
Sentry timeout filtering test coverage app/src/services/__tests__/analytics.test.ts |
Mock config adds CORE_RPC_URL and CORE_RPC_TIMEOUT_MS; captureBeforeSend updated to accept hint.originalException; tests ensure timeout errors (including cross-realm shapes) are dropped and non-timeout CoreRpcError shapes are allowed. |
Settings panel refresh error handling app/src/components/settings/panels/TeamInvitesPanel.tsx, TeamMembersPanel.tsx, TeamPanel.tsx |
Panels add debug logger and sanitizeError; refresh promise chains now include .catch(...) that logs sanitized errors and retain .finally(...) to clear loading state. TeamPanel logs CoreRpcError kind when available. |
Provider refresh error handling app/src/providers/CoreStateProvider.tsx |
After updateLocalState and after storing session token, provider invokes refresh().catch(...) to log sanitized errors and avoid propagating refresh failures as unhandled rejections. |
UI unhandled-rejection regression tests app/src/components/settings/panels/__tests__/*, app/src/providers/__tests__/CoreStateProvider.test.tsx |
New Vitest tests install window.unhandledrejection listeners and assert that panel and provider flows swallow refresh rejections (timeouts/transport) rather than surfacing unhandled promise rejections. |
Sequence Diagram
sequenceDiagram
participant Client
participant callCoreRpc
participant AbortController
participant classifyRpcError
participant Analytics_beforeSend
Client->>callCoreRpc: invoke RPC method
callCoreRpc->>AbortController: start timeout timer
AbortController->>callCoreRpc: abort on CORE_RPC_TIMEOUT_MS
callCoreRpc->>callCoreRpc: throw CoreRpcError(kind: 'timeout', message: 'Core RPC <method> timed out after Nms')
callCoreRpc->>classifyRpcError: classify error message
classifyRpcError->>classifyRpcError: return 'timeout'
callCoreRpc->>Analytics_beforeSend: error reaches Sentry hook (hint.originalException)
Analytics_beforeSend->>Analytics_beforeSend: isCoreRpcTimeoutError(hint.originalException) => true
Analytics_beforeSend->>Analytics_beforeSend: drop event (return null)
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- tinyhumansai/openhuman#2167: Modifies CoreStateProvider bootstrap/polling refresh error handling and debug logging at similar control-flow points.
Suggested reviewers
- senamakel
- graycyrus
Poem
A rabbit logs a timeout's sigh,
It classifies and gently ties.
Panels catch what used to flee,
Sentry sleeps—no noisy plea.
Hops of code, safe and spry. 🐇
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title directly and specifically describes the main changes: fixing timeout unhandled-rejections and adding a timeout classification in the RPC client, matching the PR's core objective of reducing Sentry noise from 30s RPC timeouts. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
Comment @coderabbitai help to get the list of available commands and usage tips.