Repository navigation
perf(host-cloudflare): reconcile internal integrations on a cron instead of at isolate boot - #24
Merged
Merged
Conversation
…ead of at isolate boot Cold isolates waited about 4 s on a sequential reconcile of every internal integration before serving any request (API, MCP, internal door). Reconcile now runs every minute from a cron trigger via a scheduled handler, all entries concurrently, and the fetch path no longer touches it. A new internal integration or a changed tool list now appears within about a minute instead of at isolate boot. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
…th the reconcile cron The cron reuses the per-isolate D1 handle instead of reopening D1 every minute (a failed open is retried), builds its executor on makeCloudflareExecutionStackLayer, and loads config inside a single Effect.gen so a throw still ends in the "never throws" warning. Claude-Session: https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S
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.
Why
Every new isolate awaited a sequential reconcile of all internal integrations before it served its first request. Production traces showed about 4 s of wall time per cold isolate, and every request that landed on one waited for it:
/api/*,/mcp, and the internal service-binding door.What changes
scheduledhandler withctx.waitUntil). The fetch path no longer runs it.concurrency: "unbounded"). Each entry already catches its own failure.wrangler.jsoncdeclares"triggers": { "crons": ["* * * * *"] }.Trade-off
A new internal integration, or a changed tool list, appears within about a minute instead of at isolate boot. With
wrangler dev, reconcile now runs only whenscheduledis triggered by hand.Tests
reconcile.test.ts: all entries start before any of them is released.worker.test.ts: fetch never calls reconcile, andscheduledruns one pass insidewaitUntil.https://claude.ai/code/session_019ZE3j9YzRKxT4LaiDCBv6S