Minor Changes
-
#5215
cd03d1d
Thanks @GregBrimble! - feature: customisable unsafe direct sockets entrypointsPreviously, Miniflare provided experimental
unsafeDirectHost
andunsafeDirectPort
options for starting an HTTP server that pointed directly to a specific Worker. This change replaces these options with a singleunsafeDirectSockets
option that accepts an array of socket objects of the form{ host?: string, port?: number, entrypoint?: string, proxy?: boolean }
.host
defaults to127.0.0.1
,port
defaults to0
,entrypoint
defaults todefault
, andproxy
defaults tofalse
. This allows you to start HTTP servers for specific entrypoints of specific Workers.proxy
controls theStyle
of the socket.Note these sockets set the
capnpConnectHost
workerd
option to"miniflare-unsafe-internal-capnp-connect"
.external
serviceBindings
will set theircapnpConnectHost
option to the same value allowing RPC over multipleMiniflare
instances. Refer to cloudflare/workerd#1757 for more information. -
#5215
cd03d1d
Thanks @GregBrimble! - feature: support named entrypoints forserviceBindings
This change allows service bindings to bind to a named export of another Worker using designators of the form
{ name: string | typeof kCurrentWorker, entrypoint?: string }
. Previously, you could only bind to thedefault
entrypoint. With this change, you can bind to any exported entrypoint.import { kCurrentWorker, Miniflare } from "miniflare"; const mf = new Miniflare({ workers: [ { name: "a", serviceBindings: { A_RPC_SERVICE: { name: kCurrentWorker, entrypoint: "RpcEntrypoint" }, A_NAMED_SERVICE: { name: "a", entrypoint: "namedEntrypoint" }, B_NAMED_SERVICE: { name: "b", entrypoint: "anotherNamedEntrypoint" }, }, compatibilityFlags: ["rpc"], modules: true, script: ` import { WorkerEntrypoint } from "cloudflare:workers"; export class RpcEntrypoint extends WorkerEntrypoint { ping() { return "a:rpc:pong"; } } export const namedEntrypoint = { fetch(request, env, ctx) { return new Response("a:named:pong"); } }; ... `, }, { name: "b", modules: true, script: ` export const anotherNamedEntrypoint = { fetch(request, env, ctx) { return new Response("b:named:pong"); } }; `, }, ], });
Patch Changes
-
#5499
6c3be5b
Thanks @GregBrimble! - chore: Bump workerd@1.20240403.0 -
#5215
cd03d1d
Thanks @GregBrimble! - fix: allowscript
s withoutscriptPath
s to import built-in modulesPreviously, if a string
script
option was specified withmodules: true
but without a correspondingscriptPath
, allimport
s were forbidden. This change relaxes that restriction to allow imports of built-innode:*
,cloudflare:*
andworkerd:*
modules without ascriptPath
.