Skip to content

Commit 452a4c4

Browse files
danlapidclaude
andcommitted
Add WorkerdDebugPort interface for dynamic RPC entrypoint access
Introduces a new privileged debug port interface that enables dynamic access to worker entrypoints at runtime. Currently, service bindings between workerd processes must be configured at startup in the config file. Changing binding targets requires a full process restart. This is problematic for local development tools like Miniflare, which need to dynamically re-target RPC connections at runtime. Today, Miniflare works around this by running a Node.js TCP server that sits between workerd processes and manually re-routes RPC traffic. This adds significant complexity and overhead. This commit implements the WorkerdDebugPort interface which exposes all service entrypoints in a process through a privileged RPC interface. External tools can now: - Get direct access to any entrypoint with custom props at runtime - Start events and invoke methods via JS RPC without HTTP overhead - Dynamically switch between entrypoints without process restarts This enables Miniflare to eliminate its TCP proxy layer and handle dynamic RPC routing natively through workerd. ``` interface WorkerdDebugPort { getEntrypoint(service, entrypoint, props) -> (worker) getActor(service, entrypoint, actorId) -> (actor); } ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent a51c76f commit 452a4c4

File tree

6 files changed

+573
-7
lines changed

6 files changed

+573
-7
lines changed

src/workerd/io/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ wd_capnp_library(src = "cdp.capnp")
351351
wd_capnp_library(
352352
src = "worker-interface.capnp",
353353
deps = [
354+
":frankenvalue_capnp",
354355
":outcome_capnp",
355356
":script-version_capnp",
356357
":trace_capnp",

src/workerd/io/worker-interface.capnp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ using import "/workerd/io/outcome.capnp".EventOutcome;
1616
using import "/workerd/io/script-version.capnp".ScriptVersion;
1717
using import "/workerd/io/trace.capnp".TagValue;
1818
using import "/workerd/io/trace.capnp".UserSpanData;
19+
using import "/workerd/io/frankenvalue.capnp".Frankenvalue;
1920

2021
# A 128-bit trace ID used to identify traces.
2122
struct TraceId {
@@ -696,3 +697,19 @@ interface WorkerdBootstrap {
696697
# TODO(someday): Pass cfBlobJson? Currently doesn't matter since the cf blob is only present for
697698
# HTTP requests which can be delivered over regular HTTP instead of capnp.
698699
}
700+
701+
interface WorkerdDebugPort {
702+
# Bootstrap interface exposed on the debug RPC port, if one is configured. This exposes access
703+
# to all services in the process, with the ability for the client to specify arbitrary props, so
704+
# this interface should be considered privileged, and should probably only be used for testing
705+
# purposes.
706+
#
707+
# This interface is subject to change. It is intended for use by miniflare.
708+
709+
getEntrypoint @0 (service :Text, entrypoint :Text, props :Frankenvalue)
710+
-> (entrypoint :WorkerdBootstrap);
711+
# Get direct access to a stateless entrypoint.
712+
713+
getActor @1 (service :Text, entrypoint :Text, actorId :Data) -> (actor :WorkerdBootstrap);
714+
# Get an actor (Durable Object) stub.
715+
}

0 commit comments

Comments
 (0)