Skip to content

Stop reporting remote connector websocket disconnects to Sentry - #916

Merged
kody-bot merged 1 commit into
mainfrom
cursor/sentry-triage-7631428009-cdbb
Jul 24, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/sentry-triage-7631428009-cdbb

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Sentry issue 7631428009 (code=1006 wasClean=false) and sibling 7631278616 (code=1005 wasClean=true) are warning-level captureMessage noise from RemoteConnectorSession.handleDisconnect.

Remote connector websockets disconnect constantly for expected reasons (laptop sleep, process restart, flaky home networks, DO migration). Auth failures and message-handler bugs already report at error level. This PR keeps the ops console.warn and stops opening Sentry issues for routine closes.

Test plan

  • Unit test asserts disconnect/error paths still log via console.warn and do not call Sentry.captureMessage
  • Pre-push hooks / e2e green on push

Siblings

  • 7631428009 — code=1006 abnormal close (this issue)
  • 7631278616 — code=1005 clean close (same capture site)
System recap — extends existing primitives (medium risk)

Mode: recap · Base: main @ 49893e20 · Head: 4dd51ca9

Classification: extends — remote connector session disconnects no longer open Sentry warnings; ops logging unchanged.

Primitives touched

Primitive Group Impact
connector-ingress surfaces extends — disconnect path drops Sentry captureMessage
remote-connectors assistant extends — same session DO observability policy

System map

Remote connector websocket closes used to become Sentry warnings; they now stay on worker logs only.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context.

flowchart LR
	connector["remote connector<br/>home client"]:::untouched
	session["connector-ingress<br/>Remote connector ingress"]:::extended
	logs["worker logs"]:::untouched
	sentry["Sentry"]:::untouched
	connector -->|"websocket close 1005/1006"| session
	session -->|"console.warn only"| logs
	session -.->|"no longer captureMessage"| sentry
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Before: every webSocketClose / webSocketError called Sentry.captureMessage at warning, creating issues per close code/reason.

After: disconnects log with console.warn; Sentry remains for auth/handler errors already captured at error level.

Risk and invariants

  • Medium (extends observability policy) but narrow: no auth, isolation, billing, migrations, or DR changes.
  • Per-user session DO namespacing unchanged.

Docs

No doc updates; observability policy change covered by unit tests.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of expected websocket disconnects by logging operational warnings without creating unnecessary error-monitoring alerts.
    • Preserved existing monitoring for authentication and message-handling failures.
    • Updated lifecycle checks to ensure disconnect warnings are logged consistently without duplicate error reports.

Disconnects (1005/1006 and similar) are expected lifecycle noise for home
connectors. Keep the ops console.warn; reserve Sentry for auth and handler
errors that already capture at error level.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c5dc9f97-8579-48ce-88c6-146bb9159d58

📥 Commits

Reviewing files that changed from the base of the PR and between 49893e2 and 4dd51ca.

📒 Files selected for processing (2)
  • packages/worker/src/remote-connector/session.node.test.ts
  • packages/worker/src/remote-connector/session.ts

📝 Walkthrough

Walkthrough

Websocket disconnect and error handling now emits operational console warnings without reporting expected lifecycle events to Sentry. Tests were updated to verify Sentry capture remains suppressed, including deduplication behavior.

Changes

Websocket lifecycle reporting

Layer / File(s) Summary
Disconnect warning behavior
packages/worker/src/remote-connector/session.ts, packages/worker/src/remote-connector/session.node.test.ts
handleDisconnect logs formatted disconnect warnings through console.warn without Sentry context, and lifecycle tests verify no Sentry capture occurs for close and error events.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • kentcdodds/kody#720: Both changes cover websocket lifecycle warning behavior in the remote connector tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: suppressing Sentry reporting for remote connector websocket disconnects.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-triage-7631428009-cdbb

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kody-bot
kody-bot marked this pull request as ready for review July 24, 2026 18:37
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-916.kody-a99.workers.dev

Worker: kody-pr-916
D1: kody-pr-916-db
KV: kody-pr-916-oauth-kv

Mocks:

@kody-bot
kody-bot merged commit 32d97b7 into main Jul 24, 2026
7 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-7631428009-cdbb branch July 24, 2026 18:43
kody-bot pushed a commit that referenced this pull request Jul 24, 2026
* Keep expected MCP caller errors out of Sentry

Capability handlers throw plain Errors for caller mistakes (missing
arguments, ids that do not resolve, preconditions the caller must clear)
and every one of them opened a Sentry issue that reads like a platform
bug. Five of the fourteen open kody-cloudflare issues are this class.

Adds McpCallerError so a failure site can say the caller caused it,
skips Sentry for parse_input failures (arguments never matched the
declared schema), and adds a callerError payload flag for the search
paths that report a caller mistake without throwing.

Extends the same carve-out #916 and #917 made for connector disconnects
and sandbox execute failures.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

* Stop reporting OpenAPI missing path params to Sentry

Caller mistakes like omitting organization_id_or_slug were thrown as
plain Errors from buildOperationUrl and opened Sentry issues that look
like platform bugs (KODY-CLOUDFLARE-1S). Throw McpCallerError instead so
observability keeps them on mcp-event logs only.

* Only skip Sentry for caller-attributed search batch failures

Review feedback: a total entity-batch failure could hide platform
incidents when every lookup failed for DB/load reasons. Preserve
per-entry McpCallerError provenance and set callerError only when all
failures are caller mistakes. Also mark search-detail not-found paths
as McpCallerError.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
kody-bot pushed a commit that referenced this pull request Jul 25, 2026
…#932)

* fix(sentry): stop reporting remote connector tools/list refresh noise

tools/list timeouts and disconnects during snapshot refresh are expected
home-connector lifecycle noise (same class as websocket closes in #916).
Keep the soft-fail clear + ops console.warn; reserve Sentry for auth and
handler bugs.

Refs KODY-CLOUDFLARE-24.

* fix(sentry): keep Sentry for unexpected tools/list refresh failures

Address review: only suppress expected lifecycle noise (timeout, disconnect,
not connected, connector RPC error). Malformed tools/list payloads and other
implementation errors still rethrow into the message-handler Sentry path and
do not clear a still-valid tool cache.

* fix(sentry): validate tools/list result shape before cache replace

Reject non-object results and non-array tools so malformed payloads keep the
prior tool cache and surface through the message-handler Sentry path.

* fix(sentry): harden tools/list soft-fail and result validation

Reject array-valued tools/list results, and restore the in-memory tool cache
if soft-fail persistence fails so storage bugs still reach Sentry without
blanking later reads.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

3 participants