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

Commit 57428ca

Browse files
committed
Bump versions to 2.8.0, update CHANGELOG.md and docs
1 parent ecb48fb commit 57428ca

File tree

38 files changed

+869
-345
lines changed

38 files changed

+869
-345
lines changed

docs/CHANGELOG.md

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

3+
# 2.8.0
4+
5+
## Features
6+
7+
- ⚡️ Add **custom Vitest testing environment**. This behaves almost identically
8+
to the Jest environment. However, isolated storage must be installed manually
9+
in each test file. Call the `setupMiniflareIsolatedStorage()` global function
10+
and use the returned `describe` function instead of the regular
11+
`describe`/`suite` functions imported from `vitest`. See
12+
[⚡️ Vitest Environment](https://miniflare.dev/testing/vitest) for more
13+
details.
14+
- 🌐 **Populate Workers Sites `__STATIC_CONTENT_MANIFEST`** with site files
15+
instead of an empty object. Miniflare will still disable caching of Workers
16+
Sites files to ensure the most up-to-date files are always returned. Closes
17+
[issues #233](https://github.com/cloudflare/miniflare/issues/233),
18+
[#326](https://github.com/cloudflare/miniflare/issues/326) and
19+
[cloudflare/wrangler2#1632](https://github.com/cloudflare/wrangler2/issues/1632).
20+
Thanks [@ItalyPaleAle](https://github.com/ItalyPaleAle),
21+
[@Skye-31](https://github.com/Skye-31),
22+
[@CraigglesO](https://github.com/CraigglesO),
23+
[@Hexstream](https://github.com/Hexstream) and
24+
[@PolariTOON](https://github.com/PolariTOON).
25+
-**Add global `getMiniflareWaitUntil()` method** and `ExecutionContext` class
26+
to the Jest and Vitest testing environments. This can be used to `await` the
27+
results of `waitUntil`ed `Promise`s in tests. See
28+
[🤹️ Jest Environment](https://miniflare.dev/testing/jest#waiting-for-waituntiled-promises)
29+
and
30+
[⚡️ Vitest Environment](https://miniflare.dev/testing/vitest#waiting-for-waituntiled-promises)
31+
for more details.
32+
- ⏳ Match Web Streams implementations with Workers runtime, closes issue
33+
[#168](https://github.com/cloudflare/miniflare/issues/168), thanks
34+
[@leviwolfe](https://github.com/leviwolfe):
35+
- Add support for the non-standard
36+
[`IdentityTransformStream`](https://developers.cloudflare.com/workers/runtime-apis/streams/transformstream/#identitytransformstream)
37+
class.
38+
- Add support for the **`streams_enable_constructors` compatibility flag**.
39+
`ReadableStream` and `WritableStream` constructors will throw unless this
40+
flag is enabled. `ReadableByteStreamController`,
41+
`ReadableStreamBYOBRequest`, `ReadableStreamDefaultController` and
42+
`WritableStreamDefaultController` will only be included in the sandbox if
43+
this flag is enabled.
44+
- Add support for the **`transformstream_enable_standard_constructor`
45+
compatibility flag**. `TransformStream` will behave like
46+
`IdentityTransformStream` if this isn't enabled, ignoring custom
47+
transformers. If `transformstream_enable_standard_constructor` is set, but
48+
`streams_enable_constructors` isn't, the `TransformStream` constructor will
49+
throw. `TransformStreamDefaultController` will only be included in the
50+
sandbox if both flags are enabled.
51+
- Add support for BYOB reads to the non-standard
52+
[`FixedLengthStream`](https://developers.cloudflare.com/workers/runtime-apis/streams/transformstream/#fixedlengthstream)
53+
class.
54+
- 🇬🇧 Add support for **Queues**. Docs coming soon™... 👀
55+
- 🙉 Allow calls to `addEventListener`, `removeEventListener` and
56+
`dispatchEvent` in modules mode. Please note, calling `addEventListener` with
57+
a special event type (e.g. `fetch`, `scheduled`) will log a warning prompting
58+
you to use the `export default` syntax. Closes
59+
[issue #207](https://github.com/cloudflare/miniflare/issues/207), thanks
60+
[@Electroid](https://github.com/Electroid).
61+
- 🍟 Add experimental and highly-inaccurate request CPU time measurements. These
62+
are not representative of deployed worker performance, should only be used for
63+
relative comparisons, and may be removed in the future. Enable measurements
64+
with the `--inaccurate-cpu`/`[miniflare] inaccurate_cpu`/`inaccurateCpu`
65+
option. Closes
66+
[issue #161](https://github.com/cloudflare/miniflare/issues/161). Thanks
67+
[@alexandernst](https://github.com/alexandernst) and
68+
[@y21](https://github.com/y21).
69+
- 🦄 Automatically enable watch mode when `live_reload = true` is set in
70+
`wrangler.toml`.
71+
72+
## Fixes
73+
74+
- Return `Response`s with immutable headers from `fetch`es to Durable Objects
75+
and service bindings. Closes
76+
[issue #346](https://github.com/cloudflare/miniflare/issues/346), thanks
77+
[@Cherry](https://github.com/Cherry).
78+
- Fix `CryptoKey#algorithm.name` property of `NODE-ED25519` keys. Closes
79+
[issue panva/jose#446](https://github.com/panva/jose/issues/446), thanks
80+
[@ItalyPaleAle](https://github.com/ItalyPaleAle).
81+
- Disable automatic insertion of `Sec-WebSocket-Protocol` header. Closes
82+
[issue #179](https://github.com/cloudflare/miniflare/issues/179), thanks
83+
[@aboodman](https://github.com/aboodman) and
84+
[@grgbkr](https://github.com/grgbkr).
85+
- Return `Content-Length` header is custom `Content-Encoding` is specified.
86+
Closes [issue #313](https://github.com/cloudflare/miniflare/issues/313),
87+
thanks [@vlovich](https://github.com/vlovich).
88+
- Require `"automatic"` instead of `"auto"` for the `encodeBody` option when
89+
constructing `Request`s. Closes
90+
[issue #357](https://github.com/cloudflare/miniflare/issues/357), thanks
91+
[@GregBrimble](https://github.com/GregBrimble) for
92+
[the PR](https://github.com/cloudflare/miniflare/pull/358).
93+
- Remove `request.cf.cacheTtl`/`request.cf.cacheTtlByStatus` support from the
94+
Cache API to match the behaviour of the Workers runtime, which only supports
95+
`request.cf.cacheKey`.
96+
397
# 2.7.1
498

599
## Fixes

docs/src/content/core/compatibility.md

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

7070
Specifically Miniflare supports the following flags:
7171

72+
- `streams_enable_constructors`/`streams_disable_constructors`
73+
- `transformstream_enable_standard_constructor`/`transformstream_disable_standard_constructor`
7274
- [`global_navigator`/`no_global_navigator`](https://developers.cloudflare.com/workers/platform/compatibility-dates#global-navigator)
7375
- [`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)
7476
- [`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)

docs/src/content/core/standards.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Miniflare supports the following Web Standards in its sandbox:
3333
`ReadableStreamDefaultController`, `ReadableStreamDefaultReader`,
3434
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
3535
`WritableStreamDefaultController`, `WritableStreamDefaultWriter`,
36-
`FixedLengthStream`, `CompressionStream`, `DecompressionStream`
36+
`IdentityTransformStream`, `FixedLengthStream`, `CompressionStream`,
37+
`DecompressionStream`
3738
- **Events:** `Event`, `EventTarget`, `AbortController`, `AbortSignal`
3839
- **Event Types:** `fetch`, `scheduled`, `unhandledrejection`,
3940
`rejectionhandled`

docs/src/content/developing/live-reload.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const mf = new Miniflare({
3535

3636
<Aside header="Tip">
3737

38-
When using the CLI, if `--live-reload` is set, `--watch` is automatically
39-
assumed.
38+
When using the CLI, if either `--live-reload` or `[miniflare] live_reload` is
39+
set, `--watch` is automatically assumed.
4040

4141
</Aside>
4242

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ const mf = new Miniflare({
411411
globalTimers: true, // Allow setting timers outside handlers
412412
globalRandom: true, // Allow secure random generation outside handlers
413413

414+
acutalTime: true, // Always return current time from `Date.now()`/`new Date()`
415+
416+
inaccurateCpu: true, // Log experimental, highly-inaccurate CPU time measurements with each request
417+
414418
host: "127.0.0.1", // Host for HTTP(S) server to listen on
415419
port: 8787, // Port for HTTP(S) server to listen on
416420
https: true, // Enable self-signed HTTPS (with optional cert path)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ Core Options:
275275
--global-random Allow secure random generation outside [boolean]
276276
handlers
277277
--actual-time Always return correct time from Date methods [boolean]
278+
--inaccurate-cpu Log inaccurate CPU time measurements [boolean]
278279

279280
HTTP Options:
280281
-H, --host Host for HTTP(S) server to listen on [string]
@@ -416,6 +417,8 @@ actual_time = true # --actual-time
416417
global_async_io = true # --global-async-io
417418
global_timers = true # --global-timers
418419
global_random = true # --global-random
420+
actual_time = true # --actual-time
421+
inaccurate_cpu = true # --inaccurate-cpu
419422
[miniflare.https]
420423
key = "./key.pem" # --https-key
421424
cert = "./cert.pem" # --https-cert

docs/src/content/storage/sites.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ addEventListener("fetch", (event) => {
7272

7373
When you enable Workers Sites, a read-only KV namespace, bound to
7474
`__STATIC_CONTENT`, is created using the file system (without key sanitisation)
75-
as its storage. An empty object, `{}`, is bound to `__STATIC_CONTENT_MANIFEST`.
76-
This tricks `@cloudflare/kv-asset-handler` into disabling edge caching, meaning
77-
the most up-to-date file is always loaded from disk. Miniflare also binds this
78-
empty object to the `__STATIC_CONTENT_MANIFEST` text module.
75+
as its storage. Each entry in the bound `__STATIC_CONTENT_MANIFEST` object
76+
contains a magic prefix that disables edge caching. This means the most
77+
up-to-date file are always loaded from disk. Miniflare also binds this object to
78+
the `__STATIC_CONTENT_MANIFEST` text module.

docs/src/content/testing/ava.md

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

55
# 🚀 Testing with AVA

docs/src/content/testing/jest.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,45 @@ test("mocks fetch", async () => {
296296
expect(text).toBe("Mocked response!");
297297
});
298298
```
299+
300+
## Waiting for `waitUntil`ed `Promise`s
301+
302+
To `await` the results of `waitUntil`ed `Promise`s, call the
303+
`getMiniflareWaitUntil()` global function on a `FetchEvent`, `ScheduledEvent` or
304+
`ExecutionContext`. This will return a `Promise` that resolves to an array of
305+
resolved `waitUntil`ed `Promise` values:
306+
307+
```js
308+
---
309+
filename: src/index.js
310+
---
311+
export default {
312+
async fetch(request, env, ctx) {
313+
ctx.waitUntil(Promise.resolve(1));
314+
ctx.waitUntil(Promise.resolve(2));
315+
ctx.waitUntil(Promise.resolve(3));
316+
return new Response("body");
317+
}
318+
}
319+
```
320+
321+
```js
322+
---
323+
filename: test/index.spec.js
324+
---
325+
import worker from "../src/index.js";
326+
327+
test("wait until", async () => {
328+
const request = new Request("http://localhost:8787/");
329+
const env = getMiniflareBindings();
330+
const ctx = new ExecutionContext();
331+
332+
// Call module worker handler
333+
const response = worker.fetch(request, env, ctx);
334+
expect(await response.text()).toBe("body");
335+
336+
// Check resolved values of waitUntil'ed Promises
337+
const waitUntils = await getMiniflareWaitUntil(ctx);
338+
expect(waitUntils).toEqual([1, 2, 3]);
339+
});
340+
```

0 commit comments

Comments
 (0)