Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/cloud/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const sentryOptions = (env: Env) => ({
enableLogs: true,
sendDefaultPii: true,
skipOpenTelemetrySetup: true,
// Our DO methods (init/handleRequest/alarm) live on the prototype, not on
// the instance. Sentry's default DO auto-wrap only visits own properties,
// which misses prototype methods — so errors thrown inside init() never
// reach Sentry. This flag opts into prototype-method instrumentation.
instrumentPrototypeMethods: true,
// NOTE: do NOT enable `instrumentPrototypeMethods`. It walks the DO prototype
// and reads every property — including accessors — to find methods to wrap,
// which invokes the `sessionId` getter with `this` bound to the prototype
// (where `ctx` is undefined) and throws during construction, 500ing every
// session create / cold restore. The DO captures its own errors via the
// `captureCause` seam (→ Sentry) instead.
});

// ---------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions packages/hosts/cloudflare/src/mcp/session-durable-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,10 @@ export abstract class McpSessionDOBase<
Effect.tapCause((cause) =>
Effect.gen(function* () {
console.error("[mcp-session] init failed:", Cause.pretty(cause));
// Report to the host's error sink (cloud → Sentry). init() runs on
// the prototype, which Sentry's auto-wrap doesn't cover, so capture
// here explicitly rather than relying on prototype instrumentation.
self.captureCause(cause);
// Annotate `McpSessionDO.init` (the active span here — `doInit` opens
// none of its own) so the surviving, flushed span names the frame.
yield* self.recordCauseOnSpan(cause);
Expand Down
Loading