-
#7971
ab49886
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20250124.0 1.20250129.0 @cloudflare/workers-types ^4.20250121.0 ^4.20250129.0
-
#7890
40f89a9
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241230.0 1.20250124.0 @cloudflare/workers-types ^4.20241230.0 ^4.20250121.0
- #7738
8e9aa40
Thanks @penalosa! - Use TEXT bindings for plain text values in Miniflare. This is an internal detail that should have no user facing impact.
- #7702
78bdec5
Thanks @penalosa! - Support theCF-Connecting-IP
header, which will be available in your Worker to determine the IP address of the client that initiated a request.
- #7701
2c76887
Thanks @lambrospetrou! - Fix D1 exports to properly pad HEX strings for binary values.
-
#7652
b4e0af1
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241218.0 1.20241230.0 @cloudflare/workers-types ^4.20241218.0 ^4.20241230.0
-
#7589
1488e11
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241205.0 1.20241218.0 @cloudflare/workers-types ^4.20241205.0 ^4.20241218.0 -
#7575
7216835
Thanks @LuisDuarte1! - MakeInstance.status()
return type the same as production
-
#7464
21a9e24
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241106.2 1.20241205.0 @cloudflare/workers-types ^4.20241106.0 ^4.20241205.0
-
#7418
ac87395
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241106.1 1.20241106.2 @cloudflare/workers-types ^4.20241106.0 ^4.20241106.0 -
#7399
b3d2e7d
Thanks @emily-shen! - fix: update queues max_batch_timeout limit from 30s to 60s
- #7286
563439b
Thanks @LuisDuarte1! - Add proper engine persistance in .wrangler and fix multiple workflows in miniflare
-
#7187
1db7846
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241022.0 1.20241106.1 @cloudflare/workers-types ^4.20241022.0 ^4.20241106.0
-
#7066
760e43f
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241018.1 1.20241022.0 @cloudflare/workers-types ^4.20241018.0 ^4.20241022.0 -
#7045
5ef6231
Thanks @RamIdeas! - Add preliminary support for Workflows in wrangler dev
-
#7035
809193e
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241011.1 1.20241018.1 @cloudflare/workers-types ^4.20241011.0 ^4.20241018.0
-
#6961
5761020
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20241004.0 1.20241011.1 @cloudflare/workers-types ^4.20241004.0 ^4.20241011.0 -
#6943
7859a04
Thanks @sdnts! - fix: local queues now respect consumer max delays and retry delays properly
-
#6949
c863183
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240925.0 1.20241004.0 @cloudflare/workers-types ^4.20240925.0 ^4.20241004.0
-
#6835
5c50949
Thanks @emily-shen! - fix: rename asset plugin options slightly to match wrangler.toml betterRenamed
path
->directory
,bindingName
->binding
.
-
#6826
5e2e62c
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240909.0 1.20240925.0 @cloudflare/workers-types ^4.20240909.0 ^4.20240925.0 -
#6824
1c58a74
Thanks @petebacondarwin! - fix: teach Miniflare about node_compat version date switchA compatibility of Sept 23, 2024 or later means that
nodejs_compat
is equivalent tonodejs_compat_v2
.
-
#6728
1ca313f
Thanks @emily-shen! - fix: remove filepath encoding on asset upload and handle sometimes-encoded charactersSome characters like [ ] @ are encoded by encodeURIComponent() but are often requested at an unencoded URL path. This change will make assets with filenames with these characters accessible at both the encoded and unencoded paths, but to use the encoded path as the canonical one, and to redirect requests to the canonical path if necessary.
- #6736
2ddbb65
Thanks @emily-shen! - fix: reflect file changes when using dev with workers + assets
-
#6514
2407c41
Thanks @CarmenPopoviciu! - fix: Fix Miniflare regression introduced in #5570PR #5570 introduced a regression in Miniflare, namely that declaring Queue Producers like
queueProducers: { "MY_QUEUE": "my-queue" }
no longer works. This commit fixes the issue.Fixes #5908
- #6647
d68e8c9
Thanks @joshthoward! - feat: Configure SQLite backed Durable Objects in local dev
-
#6673
3f5b934
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240821.1 1.20240909.0 @cloudflare/workers-types ^4.20240821.1 ^4.20240909.0
-
#6627
5936282
Thanks @GregBrimble! - fix: Fixes max asset count error message to properly report count of assets -
#6612
6471090
Thanks @dario-piotrowicz! - fix: add hyperdrive bindings support ingetBindings
Note: the returned binding values are no-op/passthrough that can be used inside node.js, meaning that besides direct connections via the
connect
methods, all the other values point to the same db connection specified in the user configuration
-
#6564
e8975a9
Thanks @emily-shen! - feat: add assets plugin to miniflareNew miniflare plugin for Workers + Assets, with relevant services imported from
workers-shared
.
-
#6555
b0e2f0b
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240806.0 1.20240821.1 @cloudflare/workers-types ^4.20240806.0 ^4.20240821.1
-
#6403
00f340f
Thanks @CarmenPopoviciu! - feat: Extend KV plugin behaviour to support Workers assetsThis commit extends Miniflare's KV plugin's behaviour to support Workers assets, and therefore enables the emulation of Workers with assets in local development.
-
#6438
d55eeca
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240725.0 1.20240806.0 @cloudflare/workers-types ^4.20240725.0 ^4.20240806.0
-
#6345
a9021aa
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240718.0 1.20240725.0 @cloudflare/workers-types ^4.20240718.0 ^4.20240725.0 -
#6301
44ad2c7
Thanks @dario-piotrowicz! - fix: Allow the magic proxy to proxy objects containing functions indexed by symbolsIn #5670 we introduced the possibility of the magic proxy to handle object containing functions, the implementation didn't account for functions being indexed by symbols, address such issue
- #6342
b3c3cb8
Thanks @petebacondarwin! - fix Miniflare (workerd) network settings to allow 240.0.0.0 range
-
#6294
779c713
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240712.0 1.20240718.0 @cloudflare/workers-types ^4.20240712.0 ^4.20240718.0
-
#6265
0d32448
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240701.0 1.20240712.0 @cloudflare/workers-types ^4.20240620.0 ^4.20240712.0
-
#6181
42a7930
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240620.1 1.20240701.0 -
#6127
1568c25
Thanks @DaniFoldi! - fix: Bump ws dependency
-
#6110
7d02856
Thanks @CarmenPopoviciu! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240610.1 1.20240620.1 @cloudflare/workers-types ^4.20240605.0 ^4.20240620.0
-
#6050
a0c3327
Thanks @threepointone! - chore: Normalize more depsThis is the last of the patches that normalize dependencies across the codebase. In this batch:
ws
,vitest
,zod
,rimraf
,@types/rimraf
,ava
,source-map
,glob
,cookie
,@types/cookie
,@microsoft/api-extractor
,@types/mime
,@types/yargs
,devtools-protocol
,@vitest/ui
,execa
,strip-ansi
This patch also sorts dependencies in every
package.json
-
#6029
f5ad1d3
Thanks @threepointone! - chore: Normalize some dependencies in workers-sdkThis is the first of a few expected patches that normalize dependency versions, This normalizes
undici
,concurrently
,@types/node
,react
,react-dom
,@types/react
,@types/react-dom
,eslint
,typescript
. There are no functional code changes (but there are a couple of typecheck fixes). -
#6058
31cd51f
Thanks @threepointone! - chore: Quieter buildsThis patch cleans up warnings we were seeing when doing a full build. Specifically:
- fixtures/remix-pages-app had a bunch of warnings about impending features that it should be upgraded to, so I did that. (tbh this one needs a full upgrade of packages, but we'll get to that later when we're upgrading across the codebase)
- updated
@microsoft/api-extractor
so it didn't complain that it didn't match thetypescript
version (that we'd recently upgraded) - it also silenced a bunch of warnings when exporting types from
wrangler
. We'll need to fix those, but we'll do that when we work on unstable_dev etc. - workers-playground was complaining about the size of the bundle being generated, so I increased the limit on it
-
#6024
c4146fc
Thanks @petebacondarwin! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240605.0 1.20240610.1
-
#5961
ab95473
Thanks @CarmenPopoviciu! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240524.0 1.20240605.0 @cloudflare/workers-types ^4.20240524.0 ^4.20240605.0
-
#5922
bdbb7f8
Thanks @dario-piotrowicz! - fix: Allow the magic proxy to handle functions returning functionsPreviously functions returning functions would not be handled by the magic proxy, the changes here enable the above, allowing for code such as the following:
const mf = new Miniflare(/* ... */); const { functionsFactory } = await mf.getBindings<Env>(); const fn = functionsFactory.getFunction(); const functionResult = fn();
This also works with the native workers RPC mechanism, allowing users to return functions in their RPC code.
- #5921
e0e7725
Thanks @dario-piotrowicz! - docs: add configuration section with local workerd linking to main readme
-
#5917
64ccdd6
Thanks @kossnocorp! - fix: D1's JOIN behaviour when selecting columns with the same name.Properly handle the
resultsFormat
query thatworkerd
sends. This partially fixes the JOIN bug and makes the behaviour ofraw
consistent with theworkerd
behaviour.
-
#5931
4458a9e
Thanks @CarmenPopoviciu! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240512.0 1.20240524.0 @cloudflare/workers-types ^4.20240512.0 ^4.20240524.0
-
#5827
0725f6f
Thanks @petebacondarwin! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240419.0 1.20240512.0 @cloudflare/workers-types ^4.20240419.0 ^4.20240512.0 -
#5798
89b6d7f
Thanks @RamIdeas! - fix: update miniflare's response compression to act more like Cloudflare platform
-
#5570
66bdad0
Thanks @sesteves! - feature: support delayed delivery in the miniflare's queue simulator.This change updates the miniflare's queue broker to support delayed delivery of messages, both when sending the message from a producer and when retrying the message from a consumer.
-
#5670
9b4af8a
Thanks @dario-piotrowicz! - fix: Allow the magic proxy to proxy objects containing functionsThis was previously prevented but this change removes that restriction.
-
#5682
3a0d735
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240405.0 1.20240419.0 @cloudflare/workers-types ^4.20240405.0 ^4.20240419.0 -
#5482
1b7739e
Thanks @DaniFoldi! - docs: show new Discord url everywhere for consistency. The old URL still works, but https://discord.cloudflare.com is preferred.
-
#5599
c9f081a
Thanks @penalosa! - fix: add support for wrapped bindings in magic proxycurrently
Miniflare#getBindings()
does not return proxies to providedwrappedBindings
, make sure that appropriate proxies are instead returnedExample:
import { Miniflare } from "miniflare"; const mf = new Miniflare({ workers: [ { wrappedBindings: { Greeter: { scriptName: "impl", }, }, modules: true, script: `export default { fetch(){ return new Response(''); } }`, }, { modules: true, name: "impl", script: ` class Greeter { sayHello(name) { return "Hello " + name; } } export default function (env) { return new Greeter(); } `, }, ], }); const { Greeter } = await mf.getBindings(); console.log(Greeter.sayHello("world")); // <--- prints 'Hello world' await mf.dispose();
-
#5599
c9f081a
Thanks @penalosa! - fix: add support for RPC in magic proxycurrently
Miniflare#getBindings()
does not return valid proxies to providedserviceBindings
using RPC, make sure that appropriate proxies are instead returnedExample:
import { Miniflare } from "miniflare"; const mf = new Miniflare({ workers: [ { modules: true, script: `export default { fetch() { return new Response(''); } }`, serviceBindings: { SUM: { name: "sum-worker", entrypoint: "SumEntrypoint", }, }, }, { modules: true, name: "sum-worker", script: ` import { WorkerEntrypoint } from 'cloudflare:workers'; export default { fetch() { return new Response(''); } } export class SumEntrypoint extends WorkerEntrypoint { sum(args) { return args.reduce((a, b) => a + b); } } `, }, ], }); const { SUM } = await mf.getBindings(); const numbers = [1, 2, 3]; console.log(`The sum of ${numbers.join(", ")} is ${await SUM.sum(numbers)}`); // <--- prints 'The sum of 1, 2, 3 is 6' await mf.dispose();
-
#5409
08b4908
Thanks @mrbbot! - feature: respect incomingAccept-Encoding
header and ensureAccept-Encoding
/request.cf.clientAcceptEncoding
set correctlyPreviously, Miniflare would pass through the incoming
Accept-Encoding
header to your Worker code. This change ensures this header is always set toAccept-Encoding: br, gzip
for incoming requests to your Worker. The original value ofAccept-Encoding
will be stored inrequest.cf.clientAcceptEncoding
. This matches deployed behaviour.Fixes #5246
-
#5554
9575a51
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240404.0 1.20240405.0 @cloudflare/workers-types ^4.20240404.0 ^4.20240405.0
-
#5520
9f15ce1
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240403.0 1.20240404.0 @cloudflare/workers-types ^4.20240329.0 ^4.20240404.0
-
#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"); } }; `, }, ], });
-
#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
.
-
#5491
940ad89
Thanks @dario-piotrowicz! - fix: make sure the magic proxy can handle multiple parallel r2 stream readsCurrently trying to read multiple R2 streams in parallel (via
Promise.all
for example) leads to deadlock which prevents any of the target streams from being read. This is caused by the underlying implementation only allowing a single HTTP connection to the Workers runtime at a time. This change fixes the issue by allowing multiple parallel HTTP connections.
- #5455
d994066
Thanks @mrbbot! - chore: bumpworkerd
to1.20240329.0
- #5258
fbdca7d
Thanks @OilyLime! - feature: URL decode components of the Hyperdrive config connection string
-
#5341
248a318
Thanks @dependabot! - chore: update dependencies of "miniflare" packageThe following dependency versions have been updated:
Dependency From To workerd 1.20240314.0 1.20240320.1 @cloudflare/workers-types ^4.20240314.0 ^4.20240320.1
- #5240
1720f0a
Thanks @CarmenPopoviciu! - chore: bumpworkerd
to1.20240314.0
- #5247
2e50d51
Thanks @CarmenPopoviciu! - fix: Add internal APIs to support the Workers Vitest integration
-
#5201
1235d48
Thanks @wydengyre! - fix: ensureminiflare
works with Node 21.7.0+ -
#5191
27fb22b
Thanks @mrbbot! - fix: ensure redirect responses handled correctly withdispatchFetch()
Previously, if your Worker returned a redirect response, calling
dispatchFetch(url)
would send another request to the originalurl
rather than the redirect. This change ensures redirects are followed correctly.- If your Worker returns a relative redirect or an absolute redirect with the same origin as the original
url
, the request will be sent to the Worker. - If your Worker instead returns an absolute redirect with a different origin, the request will be sent to the Internet.
- If a redirected request to a different origin returns an absolute redirect with the same origin as the original
url
, the request will also be sent to the Worker.
- If your Worker returns a relative redirect or an absolute redirect with the same origin as the original
-
#5148
11951f3
Thanks @dom96! - chore: bumpworkerd
to1.20240304.0
-
#5148
11951f3
Thanks @dom96! - fix: use python_workers compat flag for Python
-
#5133
42bcc72
Thanks @mrbbot! - fix: ensure internals can accessworkerd
when starting on non-localhost
Previously, if Miniflare was configured to start on a
host
that wasn't127.0.0.1
,::1
,*
,::
, or0.0.0.0
, calls toMiniflare
API methods relying on the magic proxy (e.g.getKVNamespace()
,getWorker()
, etc.) would fail. This change ensuresworkerd
is always accessible to Miniflare's internals. This also fixeswrangler dev
when using local network address such as192.168.0.10
with the--ip
flag. -
#5133
42bcc72
Thanks @mrbbot! - fix: ensure IPv6 addresses can be used ashost
sPreviously, if Miniflare was configured to start on an IPv6
host
, it could crash. This change ensures IPv6 addresses are handled correctly. This also fixeswrangler dev
when using IPv6 addresses such as::1
with the--ip
flag.
- #5081
0c0949d
Thanks @garrettgu10! - chore: bumpworkerd
to1.20240223.1
- #5068
b03db864
Thanks @mrbbot! - chore: bumpworkerd
to1.20240208.0
-
#4795
027f9719
Thanks @mrbbot! - feat: passMiniflare
instance as argument to custom service binding handlersThis change adds a new
Miniflare
-typed parameter to function-valued service binding handlers. This provides easy access to the correct bindings when re-using service functions across instances.import assert from "node:assert"; import { Miniflare, Response } from "miniflare"; const mf = new Miniflare({ serviceBindings: { SERVICE(request, instance) { assert(instance === mf); return new Response(); }, }, });
-
#4795
027f9719
Thanks @mrbbot! - feat: allowURL
s to be passed inhyperdrives
Previously, the
hyperdrives
option only acceptedstring
s as connection strings. This change allowsURL
objects to be passed too.
-
#4795
027f9719
Thanks @mrbbot! - feat: add support for custom root pathsMiniflare has lots of file-path-valued options (e.g.
scriptPath
,kvPersist
,textBlobBindings
). Previously, these were always resolved relative to the current working directory before being used. This change adds a newrootPath
shared, and per-worker option for customising this behaviour. Instead of resolving relative to the current working directory, Miniflare will now resolve path-valued options relative to the closestrootPath
option. Paths are still resolved relative to the current working directory if norootPath
s are defined. Worker-levelrootPath
s are themselves resolved relative to the sharedrootPath
if defined.import { Miniflare } from "miniflare"; const mf1 = new Miniflare({ scriptPath: "index.mjs", }); const mf2 = new Miniflare({ rootPath: "a/b", scriptPath: "c/index.mjs", }); const mf3 = new Miniflare({ rootPath: "/a/b", workers: [ { name: "1", rootPath: "c", scriptPath: "index.mjs", }, { name: "2", scriptPath: "index.mjs", }, ], });
-
#4795
027f9719
Thanks @mrbbot! - feat: allow easy binding to current workerPreviously, if you wanted to create a service binding to the current Worker, you'd need to know the Worker's name. This is usually possible, but can get tricky when dealing with many Workers. This change adds a new
kCurrentWorker
symbol that can be used instead of a Worker name inserviceBindings
.kCurrentWorker
always points to the Worker with the binding.import { kCurrentWorker, Miniflare } from "miniflare"; const mf = new Miniflare({ serviceBindings: { SELF: kCurrentWorker, }, modules: true, script: `export default { fetch(request, env, ctx) { const { pathname } = new URL(request.url); if (pathname === "/recurse") { return env.SELF.fetch("http://placeholder"); } return new Response("body"); } }`, }); const response = await mf.dispatchFetch("http://placeholder/recurse"); console.log(await response.text()); // body
-
#4954
7723ac17
Thanks @mrbbot! - fix: allow relativescriptPath
/modulesRoot
s to break out of current working directoryPreviously, Miniflare would resolve relative
scriptPath
s againstmoduleRoot
multiple times resulting in incorrect paths and module names. This would lead tocan't use ".." to break out of starting directory
workerd
errors. This change ensures Miniflare usesscriptPath
as is, and only resolves it relative tomodulesRoot
when computing module names. Note this bug didn't affect service workers. This allows you to reference a modulesscriptPath
outside the working directory with something like:const mf = new Miniflare({ modules: true, modulesRoot: "..", scriptPath: "../worker.mjs", });
Fixes #4721
-
#4795
027f9719
Thanks @mrbbot! - fix: return non-WebSocket responses for failed WebSocket upgradingfetch()
esPreviously, Miniflare's
fetch()
would throw an error if theUpgrade: websocket
header was set, and a non-WebSocket response was returned from the origin. This change ensures the non-WebSocket response is returned fromfetch()
instead, withwebSocket
set tonull
. This allows the caller to handle the response as they see fit.
-
#4795
027f9719
Thanks @mrbbot! - fix: ensureMiniflareOptions
,WorkerOptions
, andSharedOptions
types are correctMiniflare uses Zod for validating options. Previously, Miniflare inferred
*Options
from the output types of its Zod schemas, rather than the input types. In most cases, these were the same. However, thehyperdrives
option has different input/output types, preventing these from being type checked correctly.
-
#4950
05360e43
Thanks @petebacondarwin! - fix: ensure we do not rewrite external Origin headers in wrangler devIn #4812 we tried to fix the Origin headers to match the Host header but were overzealous and rewrote Origin headers for external origins (outside of the proxy server's origin).
This is now fixed, and moreover we rewrite any headers that refer to the proxy server on the request with the configured host and vice versa on the response.
This should ensure that CORS is not broken in browsers when a different host is being simulated based on routes in the Wrangler configuration.
-
#4905
148feff6
Thanks @dario-piotrowicz! - feature: add agetCf
method to Miniflare instancesadd a new
getCf
method attached to instances ofMiniflare
, thisgetCf
returns thecf
object that the Miniflare instance provides to the actual workers and it depends of the core option of the same nameExample:
import { Miniflare } from "miniflare"; const mf = new Miniflare({ ... }); const cf = await mf.getCf(); console.log(`country = ${cf.country} ; colo = ${cf.colo}`); // logs 'country = GB ; colo = LHR'
-
#4873
1e424ff2
Thanks @dom96! - feature: implemented basic Python supportHere is an example showing how to construct a MiniFlare instance with a Python module:
const mf = new Miniflare({ modules: [ { type: "PythonModule", path: "index", contents: "from js import Response;\ndef fetch(request):\n return Response.new('hello')", }, ], compatibilityFlags: ["experimental"], });
- #4874
749fa3c0
Thanks @mrbbot! - chore: bumpworkerd
to1.20240129.0
-
#4812
8166eefc
Thanks @petebacondarwin! - fix: ensure that Origin header is rewritten as necessaryThe
wrangler dev
command puts the Worker under test behind a proxy server. This proxy server should be transparent to the client and the Worker, which means that theRequest
arriving at the Worker with the correcturl
property, andHost
andOrigin
headers. Previously we fixed theHost
header but missed theOrigin
header which is only added to a request under certain circumstances, such as cross-origin requests.This change fixes the
Origin
header as well, so that it is rewritten, when it exists, to use theorigin
of theurl
property.Fixes #4761
- #4768
c3e410c2
Thanks @petebacondarwin! - ci: bump undici versions to 5.28.2
-
#4686
4f6999ea
Thanks @mrbbot! - feat: exposerows_read
androws_written
in D1 resultmeta
rows_read
/rows_written
contain the number of rows read from/written to the database engine when executing a query respectively. These numbers may be greater than the number of rows returned from/inserted by a query. These numbers form billing metrics when your Worker is deployed. See https://developers.cloudflare.com/d1/platform/pricing/#billing-metrics for more details.
-
#4719
c37d94b5
Thanks @mrbbot! - fix: ensureminiflare
andwrangler
can source map in the same processPreviously, if in a
wrangler dev
session you calledconsole.log()
and threw an unhandled error you'd see an error like[ERR_ASSERTION]: The expression evaluated to a falsy value
. This change ensures you can do both of these things in the same session.
-
#4630
037de5ec
Thanks @petebacondarwin! - fix: ensure User Worker gets the correct Host header in wrangler dev local modeSome full-stack frameworks, such as Next.js, check that the Host header for a server side action request matches the host where the application is expected to run.
In
wrangler dev
we have a Proxy Worker in between the browser and the actual User Worker. This Proxy Worker is forwarding on the request from the browser, but then the actual User Worker is running on a different host:port combination than that which the browser thinks it should be on. This was causing the framework to think the request is malicious and blocking it.Now we update the request's Host header to that passed from the Proxy Worker in a custom
MF-Original-Url
header, but only do this if the request also contains a shared secret between the Proxy Worker and User Worker, which is passed via theMF-Proxy-Shared-Secret
header. This last feature is to prevent a malicious website from faking the Host header in a request directly to the User Worker.
- #4684
c410ea14
Thanks @mrbbot! - chore: bumpworkerd
to1.20231218.0
-
#4448
eb08e2dc
Thanks @mrbbot! - fix: include request url and headers in pretty error pageThis change ensures Miniflare's pretty error page includes the URL and headers of the incoming request, rather than Miniflare's internal request for the page.
-
#4466
71fb0b86
Thanks @mrbbot! - fix: ensure unused KV and Cache blobs cleaned upWhen storing data in KV, Cache and R2, Miniflare uses both an SQL database and separate blob store. When writing a key/value pair, a blob is created for the new value and the old blob for the previous value (if any) is deleted. A few months ago, we introduced a change that prevented old blobs being deleted for KV and Cache. R2 was unaffected. This shouldn't have caused any problems, but could lead to persistence directories growing unnecessarily as they filled up with garbage blobs. This change ensures garbage blobs are deleted.
Note existing garbage will not be cleaned up. If you'd like to do this, download this Node script (https://gist.github.com/mrbbot/68787e19dcde511bd99aa94997b39076). If you're using the default Wrangler persistence directory, run
node gc.mjs kv .wrangler/state/v3/kv <namespace_id_1> <namespace_id_2> ...
andnode gc.mjs cache .wrangler/state/v3/cache default named:<cache_name_1> named:<cache_name_2> ...
with each of your KV namespace IDs (not binding names) and named caches.
-
#4550
63708a94
Thanks @mrbbot! - fix: validateHost
andOrgin
headers where appropriateHost
andOrigin
headers are now checked when connecting to the inspector and Miniflare's magic proxy. If these don't match what's expected, the request will fail.
-
#4505
1b348782
Thanks @mrbbot! - fix: remove__STATIC_CONTENT_MANIFEST
from module workerenv
When using Workers Sites with a module worker, the asset manifest must be imported from the
__STATIC_CONTENT_MANIFEST
virtual module. Miniflare provided this module, but also erroneously added__STATIC_CONTENT_MANIFEST
to theenv
object too. Whilst this didn't break anything locally, it could cause users to develop Workers that ran locally, but not when deployed. This change ensuresenv
doesn't contain__STATIC_CONTENT_MANIFEST
.
-
#4348
be2b9cf5
Thanks @mrbbot! - feat: add support for wrapped bindingsThis change adds a new
wrappedBindings
worker option for configuringworkerd
's wrapped bindings. These allow custom bindings to be written as JavaScript functions accepting anenv
parameter of "inner bindings" and returning the value to bind. For more details, refer to the API docs.
- #4341
d9908743
Thanks @RamIdeas! - Added ahandleRuntimeStdio
which enables wrangler (or any other direct use of Miniflare) to handle thestdout
andstderr
streams from the workerd child process. By default, if this option is not provided, the previous behaviour is retained which splits the streams into lines and callsconsole.log
/console.error
.
- #4324
16cc2e92
Thanks @penalosa! - Update to latestworkerd@1.20231030.0
-
#4322
8a25b7fb
Thanks @dario-piotrowicz! - addunsafeEvalBinding
optionAdd option to leverage the newly introduced
UnsafeEval
workerd binding API, such API is used to evaluate javascript code at runtime via the providedeval
andnewFunction
methods.The API, for security reasons (as per the workers docs), is not to be use in production but it is intended for local purposes only such as local testing.
To use the binding you need to specify a string value for the
unsafeEvalBinding
, such will be the name of theUnsafeEval
bindings that will be made available in the workerd runtime.For example the following code shows how to set the binding with the
UNSAFE_EVAL
name and evaluate the1+1
string:const mf = new Miniflare({ log, modules: true, script: ` export default { fetch(req, env, ctx) { const two = env.UNSAFE_EVAL.eval('1+1'); return new Response('two = ' + two); // returns 'two = 2' } } `, unsafeEvalBinding: "UNSAFE_EVAL", });
- #4397
4f8b3420
Thanks @mrbbot! - fix: rejectMiniflare#ready
promise ifMiniflare#dispose()
called while waiting
-
#4428
3637d97a
Thanks @mrbbot! - fix: addminiflare
bin
entryMiniflare 3 doesn't include a CLI anymore, but should log a useful error stating this when running
npx miniflare
. We had a script for this, but it wasn't correctly hooked up. 🤦 This change makes sure the requiredbin
entry exists.
-
#4321
29a59d4e
Thanks @mrbbot! - fix: ensureMutex
doesn't report itself as drained if lockedPreviously, Miniflare's
Mutex
implementation would report itself as drained if there were no waiters, regardless of the locked state. This bug meant that if you called but didn'tawait
Miniflare#setOptions()
, future calls toMiniflare#dispatchFetch()
(or any other asynchronousMiniflare
method) wouldn't wait for the options update to apply and the runtime to restart before sending requests. This change ensures we wait until the mutex is unlocked before reporting it as drained.
-
#4400
76787861
Thanks @mrbbot! - fix: cleanup temporary directory after shutting downworkerd
Previously on exit, Miniflare would attempt to remove its temporary directory before shutting down
workerd
. This could lead toEBUSY
errors on Windows. This change ensures we shutdownworkerd
before removing the directory. Since we can only clean up on a best effort basis when exiting, it also catches any errors thrown when removing the directory, in case the runtime doesn't shutdown fast enough.
For previous Miniflare 3 releases, refer to this GitHub releases page: https://github.com/cloudflare/miniflare/releases.
For previous Miniflare 1 and 2 releases, refer to this CHANGELOG
: https://github.com/cloudflare/miniflare/blob/master/docs/CHANGELOG.md