Skip to content

fix: carry request.cf through debug port capnp layer#6116

Draft
penalosa wants to merge 1 commit intomainfrom
penalosa/debug-port-cf-blob
Draft

fix: carry request.cf through debug port capnp layer#6116
penalosa wants to merge 1 commit intomainfrom
penalosa/debug-port-cf-blob

Conversation

@penalosa
Copy link
Contributor

Summary

  • Fixes request.cf being lost when requests go through the debug port (used by Miniflare's native dev registry for cross-worker service bindings)
  • The cf blob was already being passed to startRequest(metadata) by Fetcher::getClientWithTracing() but WorkerdBootstrapSubrequestChannel ignored it entirely

Changes

Sender side (workerd-debug-port-client.c++):

  • CfInjectingWorkerInterface: thin WorkerInterface wrapper that injects MF-CF-Blob header into outgoing HTTP requests when metadata.cfBlobJson is present
  • WorkerdBootstrapSubrequestChannel::startRequest() now wraps the RpcWorkerInterface with CfInjectingWorkerInterface when cf blob is provided

Receiver side (server.c++):

  • CfAwareHttpService: wraps the target service's HTTP interface, extracts MF-CF-Blob header from incoming requests, and passes cf to SubrequestMetadata
  • EventDispatcherImpl defers WorkerInterface creation until the HTTP request arrives (stores SubrequestChannel instead of WorkerInterface), enabling cf blob extraction
  • startEvent() passes kj::addRef(*service) instead of service->startRequest({})

Context

Part of cloudflare/workers-sdk#12600 — refactoring the Miniflare dev registry to use native debug port RPC instead of a Node.js HTTP proxy.

@penalosa penalosa force-pushed the penalosa/debug-port-cf-blob branch 2 times, most recently from 1702953 to 8e0854b Compare February 19, 2026 18:55
Add cfBlobJson as a parameter to WorkerdBootstrap::startEvent() in the capnp
schema, so request.cf travels as a first-class RPC value through the debug port.

Sender (workerd-debug-port-client.c++):
- startRequest() passes metadata.cfBlobJson via req.setCfBlobJson() on startEvent

Receiver (server.c++):
- startEvent() extracts cfBlobJson from RPC params, passes to EventDispatcherImpl
- getHttpService() includes cfBlobJson in SubrequestMetadata when creating WorkerInterface
- EventDispatcherImpl defers WorkerInterface creation (stores SubrequestChannel)
@penalosa penalosa force-pushed the penalosa/debug-port-cf-blob branch from 8e0854b to 3176119 Compare February 20, 2026 11:51
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will degrade performance by 21.01%

❌ 1 regressed benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
bodyWithHeaders[Response] 30.3 µs 38.3 µs -21.01%

Comparing penalosa/debug-port-cf-blob (3176119) with main (acdca96)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

Comments