Use capnweb native ReadableStream support for remote Media bindings#12582
Use capnweb native ReadableStream support for remote Media bindings#12582
capnweb native ReadableStream support for remote Media bindings#12582Conversation
🦋 Changeset detectedLatest commit: 6d5ad38 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @penalosa's task —— View job Changeset Review
The changeset description is too minimal. According to the guidelines:
The current changeset says:
This needs more context:
Per the guidelines, aim for "more than one sentence but less than three paragraphs." A good changeset should explain the reason for the change and anything notable about the approach. Suggested improvement: ---
"miniflare": patch
"wrangler": patch
---
Use capnweb's native ReadableStream support for remote Media and Dispatch Namespace bindings
Previously, remote Media bindings used an HTTP-based workaround to handle streaming data. With capnweb 0.5.0's native ReadableStream support, we've removed this intermediary HTTP layer and now communicate directly via RPC, simplifying the implementation and improving performance. |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
capnweb native ReadableStream support for remote Media bindings
fc2e1a3 to
4d0a95b
Compare
… bindings
This PR updates miniflare to use capnweb's native ReadableStream support
(via workerd entry point) for remote Media and Dispatch Namespace bindings.
Changes:
- Update capnweb to PR 139 (adds Headers/Request/Response + streams support)
- Remove custom Media binding worker - use remote-proxy-client directly
- Simplify dispatch-namespace to use service binding pattern (like Media)
- Add makeRemoteProxyStub() helper for capnweb RPC + fetch interception
- Configure esbuild with workerd conditions for capnweb workers
The dispatch-namespace binding now uses JSRPC with promise pipelining,
so `namespace.get('worker').fetch(request)` works without extra round-trips.
4d0a95b to
87328d7
Compare
- Add optional workerScript param to remoteProxyClientWorker() - Use remoteProxyClientWorker() in dispatch-namespace plugin (consistency) - Fix protocol downgrade: https→wss, http→ws (was always using ws:)
The refactor into makeRemoteProxyStub dropped the bindingType → MF-Binding-Type forwarding that the AI RPC workaround in ProxyServerWorker depends on.
…b from user worker Move capnweb out of the dispatch namespace extension module (which runs in the user's isolate) into a dedicated proxy worker accessed via service binding. The extension is now a thin shim that delegates .get() calls. Also: simplify extraContext plumbing in remote-proxy-client, revert unrelated worker-ts fixture changes.
packages/miniflare/src/workers/dispatch-namespace/dispatch-namespace-proxy.worker.ts
Outdated
Show resolved
Hide resolved
packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts
Outdated
Show resolved
Hide resolved
packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts
Outdated
Show resolved
Hide resolved
packages/miniflare/src/workers/shared/remote-proxy-client.worker.ts
Outdated
Show resolved
Hide resolved
…rker, update capnweb to 0.5.0
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Nice! 😄 looks good to me 🙂
Use capnweb's native ReadableStream support for remote Media and Dispatch Namespace bindings.
Build configuration
conditions: ["workerd", "worker", "browser"]to esbuild embed-worker plugins so capnweb resolves to its workerd entry pointMedia bindings
binding.worker.ts— Media bindings now useremoteProxyClientWorkerdirectlyevaluateMediaBinding()/isSpecialCaseMediaBindingRequest()HTTP workaround fromProxyServerWorker.tsDispatch namespace bindings
dispatch-namespace-proxy.worker.ts— proxy client that creates capnweb stubs with dispatch optionsdispatch-namespace.worker.tsto delegate to the proxy client via service bindingShared utilities
makeRemoteProxyStub()for creating capnweb-backed Fetcher proxiesremoteProxyClientWorker()script override parameter for custom proxy workersProxyMetadatatype andRemoteBindingEnvfor consistent typingDependencies
^0.5.0via pnpm catalog