Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d5606ec

Browse files
committed
Bump versions to 2.6.0, update CHANGELOG.md and docs
1 parent cc246f6 commit d5606ec

File tree

37 files changed

+757
-391
lines changed

37 files changed

+757
-391
lines changed

docs/CHANGELOG.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,77 @@
11
# 🚧 Changelog
22

3+
## 2.6.0
4+
5+
### Features
6+
7+
- 🪣 **Add support for R2 bucket bindings.** Closes
8+
[issue #276](https://github.com/cloudflare/miniflare/issues/276), thank you so
9+
much [@CraigglesO](https://github.com/CraigglesO) for
10+
[the _massive_ PR](https://github.com/cloudflare/miniflare/pull/289).
11+
- Add support for
12+
[`navigator.userAgent`](https://developers.cloudflare.com/workers/platform/compatibility-dates#global-navigator).
13+
Closes [issue #209](https://github.com/cloudflare/miniflare/issues/209),
14+
thanks [@Electroid](https://github.com/Electroid).
15+
- Return fixed time from `new Date()`/`Date.now()`, unless the
16+
`--actual-time`/`actualTime: true` option is set, to match
17+
[the behaviour the Workers runtime](https://developers.cloudflare.com/workers/learning/security-model/#step-1-disallow-timers-and-multi-threading).
18+
Closes [issue #225](https://github.com/cloudflare/miniflare/issues/225),
19+
thanks [@ItalyPaleAle](https://github.com/ItalyPaleAle).
20+
- Add support for
21+
[`(De)CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API).
22+
Closes [issue #206](https://github.com/cloudflare/miniflare/issues/206),
23+
thanks [@Electroid](https://github.com/Electroid).
24+
- Add an interactive REPL via the `--repl` flag. Any other flag can be passed
25+
too, and options will automatically be loaded from `wrangler.toml` files.
26+
Specifying a script is optional when `--repl` is enabled. The REPL can also be
27+
started programmatically via the `Miniflare#startREPL()` method. See []() for
28+
more details. Thanks [@threepointone](https://github.com/threepointone) for
29+
the idea over at
30+
[cloudflare/wrangler2#1263](https://github.com/cloudflare/wrangler2/issues/1263).
31+
32+
### Fixes
33+
34+
- Load service bindings from `services` instead of `experimental_services`, and
35+
use `binding` instead of `name` for the binding name. Thanks
36+
[@jrencz](https://github.com/jrencz) for
37+
[the PR](https://github.com/cloudflare/miniflare/pull/302).
38+
[issue #280](https://github.com/cloudflare/miniflare/issues/280).
39+
- Log warning instead of error when fetching `Request#cf` object fails. Closes
40+
[issue #224](https://github.com/cloudflare/miniflare/issues/224), thanks
41+
[@threepointone](https://github.com/threepointone).
42+
- Increase the subrequest limit for `unbound` workers from 50 to 1000, and limit
43+
the number of calls to internal APIs such as KV/Durable Object to 1000. Closes
44+
[issue #274](https://github.com/cloudflare/miniflare/issues/274), thanks
45+
[@isaac-mcfadyen](https://github.com/isaac-mcfadyen).
46+
- Fix logging of accessible hosts in Node.js 18
47+
- Remove `name` from `DurableObjectId`s in `DurableObjectState` to match the
48+
behaviour of the Workers runtime. Closes
49+
[issue #219](https://github.com/cloudflare/miniflare/issues/219).
50+
- Allow failure WebSocket upgrade responses. Closes
51+
[issue #174](https://github.com/cloudflare/miniflare/issues/174), thanks
52+
[@jinjor](https://github.com/jinjor).
53+
- Correctly handle internationalised domain names in routes. Closes
54+
[issue #186](https://github.com/cloudflare/miniflare/issues/186), thanks
55+
[@dsod](https://github.com/dsod).
56+
- Improve the error message when Durable Object bindings are missing a script to
57+
mention mounting. Closes
58+
[issue #221](https://github.com/cloudflare/miniflare/issues/221), thanks
59+
[@konsumer](https://github.com/konsumer).
60+
- Allow WebSockets to be closed without a status code. Closes
61+
[issue #284](https://github.com/cloudflare/miniflare/issues/284), thanks
62+
[@hansottowirtz](https://github.com/hansottowirtz).
63+
- Allow Durable Object alarms to be scheduled less than 30 seconds in the
64+
future. Closes
65+
[issue #290](https://github.com/cloudflare/miniflare/issues/290), thanks
66+
[@wighawag](https://github.com/wighawag) and
67+
[@CraigglesO](https://github.com/CraigglesO) for
68+
[the PR](https://github.com/cloudflare/miniflare/pull/294).
69+
- Fix `DurableObjectStorage#list()` when alarms are scheduled. Closes
70+
[issue #297](https://github.com/cloudflare/miniflare/issues/297), thanks
71+
[@evanderkoogh](https://github.com/evanderkoogh) and
72+
[@CraigglesO](https://github.com/CraigglesO) for
73+
[the PR](https://github.com/cloudflare/miniflare/pull/298).
74+
375
## 2.5.1
476

577
### ⚠️ Security Update

docs/docs-config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const logoSVGPath = path.resolve(__dirname, "..", "miniflare.svg");
5+
const logoSVGContent = fs.readFileSync(logoSVGPath, "utf8");
6+
17
module.exports = {
28
product: "Miniflare",
39
pathPrefix: "/",
4-
productIconKey: "docs-engine",
10+
productIconKey: "miniflare",
11+
logoSVGContent,
512
contentRepo: "cloudflare/miniflare",
613
contentRepoFolder: "../master/docs", // "../" removes "production/"
714
externalLinks: [

docs/miniflare.svg

Lines changed: 61 additions & 0 deletions
Loading

docs/src/content/core/compatibility.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const mf = new Miniflare({
6969

7070
Specifically Miniflare supports the following flags:
7171

72+
- [`global_navigator`/`no_global_navigator`](https://developers.cloudflare.com/workers/platform/compatibility-dates#global-navigator)
7273
- [`durable_object_fetch_requires_full_url`/`durable_object_fetch_allows_relative_url`](https://developers.cloudflare.com/workers/platform/compatibility-dates#durable-object-stubfetch-requires-a-full-url)
7374
- [`fetch_refuses_unknown_protocols`/`fetch_treats_unknown_protocols_as_http`](https://developers.cloudflare.com/workers/platform/compatibility-dates#fetch-improperly-interprets-unknown-protocols-as-http)
7475
- [`formdata_parser_supports_files`/`formdata_parser_converts_files_to_strings`](https://developers.cloudflare.com/workers/platform/compatibility-dates#formdata-parsing-supports-file)

docs/src/content/core/standards.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ Miniflare supports the following Web Standards in its sandbox:
3333
`ReadableStreamDefaultController`, `ReadableStreamDefaultReader`,
3434
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
3535
`WritableStreamDefaultController`, `WritableStreamDefaultWriter`,
36-
`FixedLengthStream`
36+
`FixedLengthStream`, `CompressionStream`, `DecompressionStream`
3737
- **Events:** `Event`, `EventTarget`, `AbortController`, `AbortSignal`
3838
- **Event Types:** `fetch`, `scheduled`, `unhandledrejection`,
3939
`rejectionhandled`
40-
- **Misc:** `structuredClone`
40+
- **Misc:** `structuredClone`, `navigator`
4141

4242
## Subrequests
4343

44-
Like the real workers runtime, Miniflare limits you to
44+
To match the behaviour of the Workers runtime, Miniflare limits you to
4545
[50 subrequests per request](https://developers.cloudflare.com/workers/platform/limits#account-plan-limits).
4646
Each call to `fetch()`, each URL in a redirect chain, and each call to a Cache
4747
API method (`put()`/`match()`/`delete()`) counts as a subrequest.
@@ -54,22 +54,56 @@ number disables the limit. Setting this to 0 disables subrequests.
5454
$ MINIFLARE_SUBREQUEST_LIMIT=100 miniflare
5555
```
5656

57+
## Frozen Time
58+
59+
To match the
60+
[behaviour of the Workers runtime](https://developers.cloudflare.com/workers/learning/security-model/#step-1-disallow-timers-and-multi-threading),
61+
Miniflare will always return the time of last I/O from `new Date()` and
62+
`Date.now()`.
63+
64+
This behaviour can be disabled by setting the `actualTime` option, which may be
65+
useful for performance testing. Note that the Miniflare
66+
[🤹 Jest Environment](/testing/jest) automatically enables this option.
67+
68+
import ConfigTabs from "../components/mdx/config-tabs";
69+
70+
<ConfigTabs>
71+
72+
```sh
73+
$ miniflare --actual-time
74+
```
75+
76+
```toml
77+
---
78+
filename: wrangler.toml
79+
---
80+
[miniflare]
81+
actual_time = true
82+
```
83+
84+
```js
85+
const mf = new Miniflare({
86+
actualTime: true,
87+
});
88+
```
89+
90+
</ConfigTabs>
91+
5792
## Global Functionality Limits
5893

59-
To match the behaviour of the Workers runtime, some functionality, such as
60-
asynchronous I/O (`fetch`, Cache API, KV), timeouts (`setTimeout`,
61-
`setInterval`), and generating cryptographically-secure random values
62-
(`crypto.getRandomValues`, `crypto.subtle.generateKey`), can only be performed
63-
while handling a request, not in the global scope.
94+
To match the
95+
[behaviour of the Workers runtime](https://developers.cloudflare.com/workers/runtime-apis/request/#the-request-context),
96+
some functionality, such as asynchronous I/O (`fetch`, Cache API, KV), timeouts
97+
(`setTimeout`, `setInterval`), and generating cryptographically-secure random
98+
values (`crypto.getRandomValues`, `crypto.subtle.generateKey`), can only be
99+
performed while handling a request, not in the global scope.
64100

65101
This behaviour can be disabled by setting the `globalAsyncIO`, `globalTimers`
66102
and `globalRandom` options respectively, which may be useful for tests or
67103
libraries that need async I/O for setup during local development. Note that the
68104
Miniflare [🤹 Jest Environment](/testing/jest) automatically enables these
69105
options.
70106

71-
import ConfigTabs from "../components/mdx/config-tabs";
72-
73107
<ConfigTabs>
74108

75109
```sh

docs/src/content/get-started/api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ const mf = new Miniflare({
447447
kvNamespaces: ["TEST_NAMESPACE"], // KV namespace to bind
448448
kvPersist: "./kv-data", // Persist KV data (to optional path)
449449

450+
r2Buckets: ["BUCKET"], // R2 bucket to bind
451+
r2Persist: "./r2-data", // Persist R2 data (to optional path)
452+
450453
durableObjects: {
451454
// Durable Object to bind
452455
TEST_OBJECT: "TestObject", // className
@@ -497,6 +500,8 @@ const waitUntil = await mf.dispatchScheduled(Date.now(), "30 * * * *");
497500

498501
const TEST_NAMESPACE = await mf.getKVNamespace("TEST_NAMESPACE");
499502

503+
const BUCKET = await mf.getR2Bucket("BUCKET");
504+
500505
const caches = await mf.getCaches(); // Get global `CacheStorage` instance
501506
const defaultCache = caches.default;
502507
const namedCache = await caches.open("name");

docs/src/content/get-started/cli.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,37 @@ $ miniflare worker.js --open # Opens http://localhost:8787
209209
$ miniflare worker.js --open https://example.com # Opens https://example.com
210210
```
211211

212+
### REPL
213+
214+
Add the `--repl` flag to start an interactive REPL session. This behaves exactly
215+
like the [Node.js REPL](https://nodejs.org/api/repl.html#repl), except you have
216+
access to Workers Runtime APIs instead. Any other Miniflare flag can be used
217+
too, with `.env`, `package.json` and `wrangler.toml` files automatically loaded.
218+
Specifying a script is optional when `--repl` is enabled, but may be required if
219+
you're using Durable Objects. If you're using an ES module format worker,
220+
bindings will be accessible via the `env` global variable.
221+
222+
```sh
223+
$ miniflare --repl --kv TEST_NAMESPACE
224+
> await new HTMLRewriter().on("p", {
225+
... element(e) {
226+
..... e.setInnerContent("new");
227+
..... }
228+
... }).transform(new Response("<p>old</p>")).text()
229+
'<p>new</p>'
230+
> await env.TEST_NAMESPACE.put("key", "value")
231+
undefined
232+
> await env.TEST_NAMESPACE.get("key")
233+
'value'
234+
>
235+
```
236+
212237
### Update Checker
213238
214239
The CLI includes an automatic update checker that looks for new versions of
215240
Miniflare once a day. As Cloudflare are always improving and tweaking workers,
216241
you should aim to install these promptly for improved compatibility with the
217-
real workers environment. You can disable this with the `--no-update-check`
242+
real Workers environment. You can disable this with the `--no-update-check`
218243
flag.
219244
220245
## Reference
@@ -234,11 +259,13 @@ Core Options:
234259
--modules-rule Modules import rule [array:TYPE=GLOB]
235260
--compat-date Opt into backwards-incompatible changes from [string]
236261
--compat-flag Control specific backwards-incompatible changes [array]
262+
--usage-model Usage model (bundled by default) [string]
237263
-u, --upstream URL of upstream origin [string]
238264
-w, --watch Watch files for changes [boolean]
239265
-d, --debug Enable debug logging [boolean]
240266
-V, --verbose Enable verbose logging [boolean]
241267
--(no-)update-check Enable update checker (enabled by default) [boolean]
268+
--repl Enable interactive REPL [boolean]
242269
--root Path to resolve files relative to [string]
243270
--mount Mount additional named workers [array:NAME=PATH[@ENV]]
244271
--name Name of service [string]
@@ -247,6 +274,7 @@ Core Options:
247274
--global-timers Allow setting timers outside handlers [boolean]
248275
--global-random Allow secure random generation outside [boolean]
249276
handlers
277+
--actual-time Always return correct time from Date methods [boolean]
250278

251279
HTTP Options:
252280
-H, --host Host for HTTP(S) server to listen on [string]
@@ -275,6 +303,10 @@ KV Options:
275303
-k, --kv KV namespace to bind [array]
276304
--kv-persist Persist KV data (to optional path) [boolean/string]
277305

306+
R2 Options:
307+
-r, --r2 R2 bucket to bind [array]
308+
--r2-persist Persist R2 data (to optional path) [boolean/string]
309+
278310
Durable Objects Options:
279311
-o, --do Durable Object to bind [array:NAME=CLASS[@MOUNT]]
280312
--do-persist Persist Durable Object data (to [boolean/string]
@@ -323,6 +355,10 @@ kv_namespaces = [ # --kv
323355
{ binding = "TEST_NAMESPACE", id = "", preview_id = "" }
324356
]
325357

358+
r2_buckets = [ # --r2
359+
{ binding = "BUCKET", bucket_name = "" }
360+
]
361+
326362
[durable_objects]
327363
bindings = [ # --do
328364
{ name = "OBJECT", class_name = "Object" }
@@ -366,6 +402,7 @@ watch = true # --watch
366402
live_reload = true # --live-reload
367403
env_path = ".env.test" # --env
368404
kv_persist = true # --kv-persist
405+
r2_persist = true # --r2-persist
369406
cache_persist = "./cache" # --cache-persist
370407
cache = false # --no-cache
371408
durable_objects_persist = true # --do-persist
@@ -375,6 +412,7 @@ cf_fetch = "./cf.json" # --cf-fetch ./cf.json
375412
cf_fetch = false # --no-cf-fetch
376413
https = true # --https
377414
https = "./cert_cache" # --https ./cert_cache
415+
actual_time = true # --actual-time
378416
global_async_io = true # --global-async-io
379417
global_timers = true # --global-timers
380418
global_random = true # --global-random

docs/src/content/storage/cache.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
order: 2
2+
order: 3
33
---
44

55
# ✨ Cache

0 commit comments

Comments
 (0)