Skip to content

fix(mcp): make the deferred tools revision on first use - #77

Merged
ALikesToCode merged 1 commit into
mainfrom
fix/deferred-tools-global-scope
Oct 9, 2026
Merged

ALikesToCode merged 1 commit into
mainfrom
fix/deferred-tools-global-scope

Conversation

@ALikesToCode

Copy link
Copy Markdown
Owner

Summary

Merging #14 to main did not deploy. Workers Builds ran wrangler deploy, and Cloudflare rejected the upload:

Uncaught Error: Disallowed operation called within global scope ... generating random values are not allowed within global scope.
    at worker/knowledge/deferred-tools.mjs:11:32

Production kept running the previous version, so nothing broke.

Line 11 created a random per-isolate revision at module load (const processRevision = crypto.randomUUID()). It is now created on first use, so it keeps the same meaning: one random revision per isolate.

Why CI missed it

  • The cloudflare-build job only runs wrangler deploy --dry-run, which bundles the Worker but never evaluates its global scope.
  • The Workers Builds previews for these branches stopped earlier, at the Durable Object migration that wrangler versions upload cannot apply.

So nothing loaded the full Worker before the production upload.

Tests

  • A new test in tests/test_deferred_tools_worker.mjs fails if loading the module makes a random value. It fails on main and passes here.
  • npm run test:worker: 1,891 passed.
  • wrangler dev --local boots the full Worker here. On main it fails to start with the same error Cloudflare reported.

Workers reject random values in global scope, so deploying main failed
with "Disallowed operation called within global scope" at
worker/knowledge/deferred-tools.mjs:11. The per-isolate revision is now
created on first use. A test fails if loading the module makes a random
value.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c06dc1f-aa2f-4e8a-b97a-c57176f10e52

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
multillm-proxy 9d94815 Oct 09 2026, 11:04 AM

@ALikesToCode
ALikesToCode merged commit 0b0e0e2 into main Oct 9, 2026
6 of 7 checks passed
@ALikesToCode
ALikesToCode deleted the fix/deferred-tools-global-scope branch October 26, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant