Repository navigation
fix(telemetry): Report createMcpHandler errors from the Worker - #72
Merged
Merged
Conversation
The Worker built its MCP handler without an onerror callback, so faults the handler catches itself never reached Sentry. Two cases had no signal at all: failures it answers with a 500 from inside the handler, and subscriptions/listen calls refused at the 1,024-stream limit, which answer HTTP 200 with a JSON-RPC error and so look like success in the app.server.response metric. The callback captures everything except the client rejections the handler also routes there (unsupported protocol revision, failed header or envelope checks, wrong content type), which already answer 4xx. Co-authored-by: Claude <claude@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to a review finding on #67.
src/worker.tsbuilds its handler withcreateMcpHandler(...)but gave it noonerror. The STDIO entry point has one; the Worker did not. The handler catches some faults itself and only reports them through that callback, so Sentry never saw them:try/catcharoundworkerMcpHandler.fetchnever sees them.subscriptions/listenrefused at the subscription limit (1,024 open streams). The SDK answers HTTP 200 with a JSON-RPC-32603, soapp.server.responsecounts it as a success.Change
onerrornow callsSentry.captureException, except for client rejections.isMcpClientRejection(insrc/telemetry.ts) matches the rejections the handler sends to the same callback:UnsupportedProtocolVersionError,Rejected …header and envelope checks, andUnsupported Media Type. The handler already answers each one with a 4xx that the response metric counts, so capturing them would only add scanner and misconfigured-client noise.Notes for review
beforeSendanonymization as every other error event. The SDK error messages contain no request bodies or headers.errorDropReasonare not affected.Checks
pnpm typecheck(Worker + Node),pnpm buildpnpm test: 299 passedCreated with Claude Code