-
Notifications
You must be signed in to change notification settings - Fork 886
Miniflare Durable Objects polyfill conflicts with Sentry instrumentation #9169
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
Comments
FWIW the polyfill is from esbuild – that's how it transforms private fields (including the WeakMap stuff) |
I have dug around a bit and it seems that the problem is actually with the build of the Cloudflare Agents library. This is the line that probably needs fixing: https://github.com/cloudflare/agents/blob/main/tsconfig.base.json#L14 |
I created an issue on the Agents repo: cloudflare/agents#264 |
Fixed in [email protected] |
thank you all! |
Uh oh!
There was an error while loading. Please reload this page.
Which Cloudflare product(s) does this pertain to?
Miniflare
What versions & operating system are you using?
MacOS (but should apply everywhere), Wrangler compat-date 2025-03-21
Please provide a link to a minimal reproduction
getsentry/sentry-mcp#134 - clone the repo at this commit
Describe the Bug
Sentry has instrumentation for
@modelcontextprotocol/sdk
package, released in9.13.0
of the Sentry SDKs.Under the hood, this monkeypatches the MCP instance via Proxies: https://github.com/getsentry/sentry-javascript/blob/57893e2e61a2677fffd8bfc226f0ed60097500f3/packages/core/src/mcp-server.ts#L49
It seems like Miniflare is using a polyfill for private class fields/methods. The MCP transport that the cloudflare
agents
library configure uses private fields/methods. The polyfill minflare seems to work by doing WeakMap<Transport, PrivateField> mappings.The Sentry instrumentation intercepts whatever transport is passed into the MCP server, Proxys it and forwards it to the MCP server. The problem is that the proxying is actually changing the identity of the transport, which will break the WeakMap.
Is it possible we can improve this polyfill so we don't break proxies? We rely on this for instrumentation, and theres not a better way to patch the library for now.
As an alternative, we could disable the patching just in miniflare, but we'd need a good way to detect this.
Please provide any relevant error logs
The error message we get is not very useful:
ref: getsentry/sentry-mcp#136
The text was updated successfully, but these errors were encountered: