Skip to content

Add workerdDebugPort binding for dynamic worker access#5652

Merged
danlapid merged 3 commits intomainfrom
dlapid/debug-port-binding
Dec 8, 2025
Merged

Add workerdDebugPort binding for dynamic worker access#5652
danlapid merged 3 commits intomainfrom
dlapid/debug-port-binding

Conversation

@danlapid
Copy link
Copy Markdown
Collaborator

@danlapid danlapid commented Dec 6, 2025

This binding allows a worker to dynamically connect to another workerd instance's debug port and access worker entrypoints via RPC, without requiring static configuration.

The binding provides two methods:

  • getEntrypoint(service, entrypoint?, props?): Access stateless entrypoints
  • getActor(service, entrypoint, actorId): Access Durable Object instances

This is a workerd-only API intended for local development and testing.

Written in conjunction with Claude, Sonnet was unable to write this in a way that I liked but opus was actually very very close!

@danlapid danlapid force-pushed the dlapid/debug-port-binding branch 8 times, most recently from 3a47fed to 3ddde6d Compare December 7, 2025 00:45
@danlapid danlapid requested a review from kentonv December 7, 2025 00:46
@danlapid danlapid marked this pull request as ready for review December 7, 2025 00:46
@danlapid danlapid requested review from a team as code owners December 7, 2025 00:46
@danlapid
Copy link
Copy Markdown
Collaborator Author

danlapid commented Dec 7, 2025

@kentonv This PR should be ready for review now, no rush though.

@danlapid danlapid force-pushed the dlapid/debug-port-binding branch from 95aadda to 0e897d7 Compare December 8, 2025 00:36
Copy link
Copy Markdown
Member

@kentonv kentonv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test?

Could have a test that just connects to its own debug port. Maybe provide a method on the binding to get this process's own debug port address.

EDIT: Sorry, missed server-test. Was looking for a wd-test for some reason.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #5652 will improve performances by 10.18%

Comparing dlapid/debug-port-binding (bd8bec4) with main (3378969)

Summary

⚡ 1 improvement
✅ 56 untouched
⏩ 30 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
simpleStringBody[Response] 22 µs 19.9 µs +10.18%

Footnotes

  1. 30 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.

This binding allows a worker to dynamically connect to another workerd
instance's debug port and access worker entrypoints via RPC, without
requiring static configuration.

The binding provides two methods:
- getEntrypoint(service, entrypoint?, props?): Access stateless entrypoints
- getActor(service, entrypoint, actorId): Access Durable Object instances

This is a workerd-only API intended for local development and testing.

Written in conjunction with Claude, Sonnet was unable to write this in a
way that I liked but opus was actually very very close!
Change the workerdDebugPort binding API from static address configuration
to a dynamic connect() method. Instead of configuring the remote address
in the config file, the binding now provides a connect(address) method
that returns a WorkerdDebugPortClient.

New API:
  const client = await env.DEBUG_PORT.connect("localhost:1234");
  const fetcher = await client.getEntrypoint("service", "entrypoint", props);
  const actor = await client.getActor("service", "class", actorId);
@danlapid danlapid force-pushed the dlapid/debug-port-binding branch from 00a5b4c to bd8bec4 Compare December 8, 2025 17:41
@danlapid danlapid merged commit 5dc0679 into main Dec 8, 2025
30 of 33 checks passed
@danlapid danlapid deleted the dlapid/debug-port-binding branch December 8, 2025 18:54
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.

4 participants