|
1 | 1 | # 🚧 Changelog |
2 | 2 |
|
| 3 | +## 2.9.0 |
| 4 | + |
| 5 | +### Features |
| 6 | + |
| 7 | +- 💾 **Add support for D1. Closes |
| 8 | + [issue #277](https://github.com/cloudflare/miniflare/issues/277), thanks |
| 9 | + [@geelen](https://github.com/geelen) for |
| 10 | + [the PR](https://github.com/cloudflare/miniflare/pull/329).** Docs coming |
| 11 | + soon™... 👀 |
| 12 | +- 🚪 **Add `getMiniflareDurableObjectState()` and |
| 13 | + `runWithMiniflareDurableObjectGates()` functions** to the Jest/Vitest |
| 14 | + environments. This allows you to construct and call instance methods of |
| 15 | + Durable Objects directly, without having to fetch through a stub. Closes |
| 16 | + [issue #157](https://github.com/cloudflare/miniflare/issues/157), thanks |
| 17 | + [@jorroll](https://github.com/jorroll). |
| 18 | + |
| 19 | + ```js |
| 20 | + // Durable Object class, would probably come from an import |
| 21 | + class Counter { |
| 22 | + constructor(state) { |
| 23 | + this.storage = state.storage; |
| 24 | + } |
| 25 | + async fetch() { |
| 26 | + const count = ((await this.storage.get("count")) ?? 0) + 1; |
| 27 | + void this.storage.put("count", count); |
| 28 | + return new Response(String(count)); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + const env = getMiniflareBindings(); |
| 33 | + // Use standard Durable Object bindings to generate IDs |
| 34 | + const id = env.COUNTER.newUniqueId(); |
| 35 | + // Get DurableObjectState, and seed data |
| 36 | + const state = await getMiniflareDurableObjectState(id); |
| 37 | + await state.storage.put("count", 3); |
| 38 | + // Construct object directly |
| 39 | + const object = new Counter(state, env); |
| 40 | + // Call instance method directly, closing input gate, |
| 41 | + // and waiting for output gate to open |
| 42 | + const res = await runWithMiniflareDurableObjectGates(state, () => |
| 43 | + object.fetch(new Request("http://localhost/")) |
| 44 | + ); |
| 45 | + expect(await res.text()).toBe("4"); |
| 46 | + ``` |
| 47 | +
|
| 48 | +- 🥷 Don't construct corresponding Durable Object instance when calling |
| 49 | + `Miniflare#getDurableObjectStorage()`. This allows you to seed data _before_ |
| 50 | + your Durable Object's constructor is invoked. Closes |
| 51 | + [issue #300](https://github.com/cloudflare/miniflare/issues/300), thanks |
| 52 | + [@spigaz](https://github.com/spigaz). |
| 53 | +- ☑️ **Add support for `WebSocket#readyState`** and |
| 54 | + `WebSocket.READY_STATE_{CONNECTING,OPEN,CLOSING,CLOSED}` constants. Note these |
| 55 | + constant names intentionally deviate from |
| 56 | + [the spec](https://websockets.spec.whatwg.org/#interface-definition) to match |
| 57 | + the Workers runtime. |
| 58 | +- 📜 **Add persistent history to the REPL.** This respects the |
| 59 | + `MINIFLARE_REPL_HISTORY`, `MINIFLARE_REPL_HISTORY_SIZE`, and |
| 60 | + `MINIFLARE_REPL_MODE` environment variables |
| 61 | + [based on Node's](https://nodejs.org/api/repl.html#environment-variable-options). |
| 62 | +- 💵 **Add support for `Range`, `If-Modified-Since` and `If-None-Match` |
| 63 | + headers** on `Request`s to `Cache#match`. Closes |
| 64 | + [issue #246](https://github.com/cloudflare/miniflare/issues/246). |
| 65 | +
|
| 66 | +### Fixes |
| 67 | +
|
| 68 | +- Don't wait for `waitUntil` `Promise`s to resolve before opening WebSocket |
| 69 | + connections |
| 70 | +- Allow WebSockets to be `close()`d on receiving a `close` event. Closes |
| 71 | + [issue #331](https://github.com/cloudflare/miniflare/issues/331), thanks |
| 72 | + [@awthwathje](https://github.com/awthwathje). |
| 73 | +- Ensure calling `WebSocket#close()` before returning a WebSocket response sends |
| 74 | + the correct close code and reason. |
| 75 | +- Fix delivery of incoming `WebSocket` `error` events |
| 76 | +- Ensure only scheduled Durable Object alarms are flushed. Previously, flushing |
| 77 | + all alarms would attempt to execute the `alarm` handler of every constructed |
| 78 | + Durable Object instance, even if that instance hadn't scheduled an alarm, or |
| 79 | + didn't have an `alarm` handler. |
| 80 | +- Delay scheduled missed alarms. Previously, if Durable Object persistence was |
| 81 | + enabled, and an alarm should've executed when Miniflare wasn't running, |
| 82 | + Miniflare may have crashed on startup. Closes |
| 83 | + [issue #359](https://github.com/cloudflare/miniflare/issues/359), thanks |
| 84 | + [@AlCalzone](https://github.com/AlCalzone). |
| 85 | +- Allow empty-chunk writes to `IdentityTransformStream`. Closes |
| 86 | + [issue #374](https://github.com/cloudflare/miniflare/issues/374), thanks |
| 87 | + [@cdloh](https://github.com/cdloh). |
| 88 | +- Don't hang when fetching from Durable Objects with fake-timers installed. |
| 89 | + Closes [issue #190](https://github.com/cloudflare/miniflare/issues/190), |
| 90 | + thanks [@vlovich](https://github.com/vlovich). |
| 91 | +- Match unimplemented `Request`/`Response` properties with the Workers runtime. |
| 92 | + Specifically, throw unimplemented errors when attempting to access |
| 93 | + `Request#{context,mode,credentials,integrity,cache}` and |
| 94 | + `Response#{type,useFinalUrl}`. |
| 95 | +- Discard `Content-Length: NaN` headers as a temporary workaround until |
| 96 | + [cloudflare/kv-asset-handler#295](https://github.com/cloudflare/kv-asset-handler/pull/295) |
| 97 | + is released. Closes |
| 98 | + [honojs/hono#520](https://github.com/honojs/hono/issues/520), thanks |
| 99 | + [@Cherry](https://github.com/Cherry). |
| 100 | +- Return byte streams when `tee()`ing byte streams to match the behaviour of the |
| 101 | + Workers runtime. Closes |
| 102 | + [issues #317](https://github.com/cloudflare/miniflare/issues/317) and |
| 103 | + [#375](https://github.com/cloudflare/miniflare/issues/375). |
| 104 | +- Throw `TypeError` when calling `Fetcher#fetch` with an illegal this to match |
| 105 | + the behaviour of the Workers runtime. |
| 106 | +
|
3 | 107 | ## 2.8.2 |
4 | 108 |
|
5 | 109 | ### Fixes |
|
0 commit comments