Skip to content

9.15.0 breaks Cloudflare SDK usage in sentry-mcp #16182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AbhiPrasad opened this issue May 1, 2025 · 5 comments · Fixed by #16180
Open

9.15.0 breaks Cloudflare SDK usage in sentry-mcp #16182

AbhiPrasad opened this issue May 1, 2025 · 5 comments · Fixed by #16180
Assignees

Comments

@AbhiPrasad
Copy link
Member

Description

getsentry/sentry-mcp#136

3:24:55 PM [vite] Internal server error: Cannot read from private field
@sentry/mcp-cloudflare:dev:       at async ProxyServer.fetch (file:///home/dcramer/src/sentry-mcp/node_modules/.pnpm/[email protected]/node_modules/miniflare/src/workers/core/proxy.worker.ts:173:11)
^C    ...Finishing writing to cache...   

AI summary:

Based on the code and error message, I can identify the issue. The error is occurring because there's a conflict between how Miniflare (the local development environment for Cloudflare Workers) handles private fields and how the Sentry SDK is trying to access them.

This suggests that the issue is related to how Miniflare v4 handles private fields in its proxy implementation, and how the Sentry SDK is trying to access these fields through its proxy wrapper.
Here are a few potential solutions:

  1. Update Miniflare to a newer version if available, as this might be a known issue that's been fixed.
  2. Modify the proxy implementation in the Sentry SDK to handle private fields differently.
  3. Use a different approach for wrapping the fetch handler that doesn't rely on accessing private fields.

I think we should try catch it.

@AbhiPrasad
Copy link
Member Author

This is still happening

@AbhiPrasad AbhiPrasad reopened this May 1, 2025
@AbhiPrasad
Copy link
Member Author

This was introduced with #16126

specifically the transport patch:

const patchedTransport = new Proxy(transport, {
set(target, key, value) {
if (key === 'onmessage') {
target[key] = new Proxy(value, {
apply(onMessageTarget, onMessageThisArg, onMessageArgArray) {
const [jsonRpcMessage] = onMessageArgArray;
if (transport.sessionId && isJsonRPCMessageWithRequestId(jsonRpcMessage)) {
handleTransportOnMessage(transport.sessionId, jsonRpcMessage.id);
}
return Reflect.apply(onMessageTarget, onMessageThisArg, onMessageArgArray);
},
});
} else if (key === 'onclose') {
target[key] = new Proxy(value, {
apply(onCloseTarget, onCloseThisArg, onCloseArgArray) {
if (transport.sessionId) {
handleTransportOnClose(transport.sessionId);
}
return Reflect.apply(onCloseTarget, onCloseThisArg, onCloseArgArray);
},
});
} else {
target[key as keyof MCPTransport] = value;
}
return true;
},
});
return Reflect.apply(target, thisArg, [patchedTransport, ...restArgs]);
},
});

this is the miniflare code: https://github.com/cloudflare/workers-sdk/blob/f901e14e842b57c90729d6f5c2b308f60323aaba/packages/miniflare/src/workers/core/proxy.worker.ts#L171-L181

and this is the agents code: https://github.com/cloudflare/agents/blob/dc0e8de4d4717c83fa3850853d125cfe047a9443/packages/agents/src/mcp/index.ts#L324

Copy link
Contributor

github-actions bot commented May 7, 2025

A PR closing this issue has just been released 🚀

This issue was referenced by PR #16180, which was included in the 9.16.0 release.

Copy link
Member Author

Created issue w/ cloudflare here: cloudflare/workers-sdk#9169

@AbhiPrasad
Copy link
Member Author

Fix was released with cloudflare/workers-sdk#9169 (comment)

We need to bump sentry-mcp to validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant