v2.9.0
Features
-
๐พ Add support for D1. Closes issue #277, thanks @geelen for the PR. Docs coming soonโข... ๐
-
๐ช Add
getMiniflareDurableObjectState()
andrunWithMiniflareDurableObjectGates()
functions to the Jest/Vitest environments. This allows you to construct and call instance methods of Durable Objects directly, without having to fetch through a stub. Closes issue #157, thanks @jorroll.// Durable Object class, would probably come from an import class Counter { constructor(state) { this.storage = state.storage; } async fetch() { const count = ((await this.storage.get("count")) ?? 0) + 1; void this.storage.put("count", count); return new Response(String(count)); } } const env = getMiniflareBindings(); // Use standard Durable Object bindings to generate IDs const id = env.COUNTER.newUniqueId(); // Get DurableObjectState, and seed data const state = await getMiniflareDurableObjectState(id); await state.storage.put("count", 3); // Construct object directly const object = new Counter(state, env); // Call instance method directly, closing input gate, // and waiting for output gate to open const res = await runWithMiniflareDurableObjectGates(state, () => object.fetch(new Request("http://localhost/")) ); expect(await res.text()).toBe("4");
-
๐ฅท Don't construct corresponding Durable Object instance when calling
Miniflare#getDurableObjectStorage()
. This allows you to seed data before your Durable Object's constructor is invoked. Closes issue #300, thanks @spigaz. -
โ๏ธ Add support for
WebSocket#readyState
andWebSocket.READY_STATE_{CONNECTING,OPEN,CLOSING,CLOSED}
constants. Note these constant names intentionally deviate from the spec to match the Workers runtime. -
๐ Add persistent history to the REPL. This respects the
MINIFLARE_REPL_HISTORY
,MINIFLARE_REPL_HISTORY_SIZE
, andMINIFLARE_REPL_MODE
environment variables based on Node's. -
๐ต Add support for
Range
,If-Modified-Since
andIf-None-Match
headers onRequest
s toCache#match
. Closes issue #246.
Fixes
- Don't wait for
waitUntil
Promise
s to resolve before opening WebSocket connections - Allow WebSockets to be
close()
d on receiving aclose
event. Closes issue #331, thanks @awthwathje. - Ensure calling
WebSocket#close()
before returning a WebSocket response sends the correct close code and reason. - Fix delivery of incoming
WebSocket
error
events - Ensure only scheduled Durable Object alarms are flushed. Previously, flushing all alarms would attempt to execute the
alarm
handler of every constructed Durable Object instance, even if that instance hadn't scheduled an alarm, or didn't have analarm
handler. - Delay scheduled missed alarms. Previously, if Durable Object persistence was enabled, and an alarm should've executed when Miniflare wasn't running, Miniflare may have crashed on startup. Closes issue #359, thanks @AlCalzone.
- Allow empty-chunk writes to
IdentityTransformStream
. Closes issue #374, thanks @cdloh. - Don't hang when fetching from Durable Objects with fake-timers installed. Closes issue #190, thanks @vlovich.
- Match unimplemented
Request
/Response
properties with the Workers runtime. Specifically, throw unimplemented errors when attempting to accessRequest#{context,mode,credentials,integrity,cache}
andResponse#{type,useFinalUrl}
. - Discard
Content-Length: NaN
headers as a temporary workaround until cloudflare/kv-asset-handler#295 is released. Closes honojs/hono#520, thanks @Cherry. - Return byte streams when
tee()
ing byte streams to match the behaviour of the Workers runtime. Closes issues #317 and #375. - Throw
TypeError
when callingFetcher#fetch
with an illegal this to match the behaviour of the Workers runtime.