fix: resolve Workers runtime compatibility issues for Cloudflare Browser Rendering#54
Open
ebrainte wants to merge 2 commits into
Open
fix: resolve Workers runtime compatibility issues for Cloudflare Browser Rendering#54ebrainte wants to merge 2 commits into
ebrainte wants to merge 2 commits into
Conversation
…oyment - Bump compatibility_date to 2025-09-23 for fs.mkdir support in Workers - Pin @cloudflare/playwright to 1.1.2 with patch replacing fs.mkdtemp (not implemented in Workers nodejs_compat) with fs.mkdir + random suffix - Upgrade agents to ^0.4.0 to fix MCP Server 'Already connected to a transport' error on Durable Object hibernation wake-up (CVE-2026-25536) - Fix vite.config.ts fs alias: use node:fs instead of @cloudflare/playwright/fs
c828bc0 to
f171003
Compare
zod-to-json-schema 3.25.x produces empty schemas (strips type, properties, etc.), causing MCP clients to reject all tool definitions with schema validation errors. Pin to tilde range ~3.24.6 so only patch updates within 3.24.x are allowed.
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.
Summary
The Cloudflare example (
cloudflare/example/) fails to deploy because of three interrelated runtime compatibility issues in the Workers environment. This PR fixes all three.Bug 1:
fs.mkdtempnot available in WorkersRoot cause:
vite.config.tsaliases bothfsandnode:fsto@cloudflare/playwright/fs, but that shim does not implementmkdtemp. When@cloudflare/playwrightcallsfs.promises.mkdtemp()during browser launch, it crashes.Fix:
fs→node:fsinstead of@cloudflare/playwright/fs(removes thenode:fsalias too — onlyfsalias needed)node:fs(not@cloudflare/playwright/fs)@cloudflare/playwright@1.1.2to replacemkdtempcalls withmkdir+ random suffix (3 locations inbrowserType.jsandchromium.js)Bug 2:
compatibility_datetoo old forfs.mkdirRoot cause:
wrangler.tomlhascompatibility_date = "2025-03-10", butnode:fs.mkdirrequires>= 2025-09-23.Fix: Update
compatibility_dateto2025-09-23.Bug 3: Durable Object hibernation crash — "Already connected to a transport"
Root cause: When the
McpAgentDurable Object hibernates and wakes up,onStart()callsserver.connect(transport)but the MCPServerinstance still thinks it's connected from before hibernation. It throws"Already connected to a transport".Fix: Upgrade
agentsfrom^0.0.109to^0.4.0. As identified in cloudflare/agents#1239, this was caused by a security issue (CVE-2026-25536 / GHSA-345p-7cg4-v4c7) in@modelcontextprotocol/sdk < 1.26.0— reusing server/transport instances can leak cross-client data.agents@0.4.0+includes@modelcontextprotocol/sdk@1.26.0which creates fresh Server/transport instances per connection, fixing both the crash and the security vulnerability.Changes
cloudflare/vite.config.tsfs/node:fsalias →node:fs; external@cloudflare/playwright/fs→node:fscloudflare/example/wrangler.tomlcompatibility_date→2025-09-23cloudflare/package.json@cloudflare/playwrightto1.1.2, upgradeagentsto^0.4.0, addpatch-packagecloudflare/patches/@cloudflare+playwright+1.1.2.patchmkdtemp→mkdir+ random suffixTesting
Deployed and verified on two separate Cloudflare accounts (free and paid Workers plans). All MCP tools (
browser_navigate,browser_snapshot,browser_take_screenshot,browser_close) work correctly after these fixes. Tested with bothagents@0.4.0(no patches) confirming the Durable Object hibernation issue is fully resolved.