Skip to content

Commit

Permalink
Bump versions to 2.6.0, update CHANGELOG.md and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Jul 9, 2022
1 parent cc246f6 commit d5606ec
Show file tree
Hide file tree
Showing 37 changed files with 757 additions and 391 deletions.
72 changes: 72 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
# 🚧 Changelog

## 2.6.0

### Features

- 🪣 **Add support for R2 bucket bindings.** Closes
[issue #276](https://github.com/cloudflare/miniflare/issues/276), thank you so
much [@CraigglesO](https://github.com/CraigglesO) for
[the _massive_ PR](https://github.com/cloudflare/miniflare/pull/289).
- Add support for
[`navigator.userAgent`](https://developers.cloudflare.com/workers/platform/compatibility-dates#global-navigator).
Closes [issue #209](https://github.com/cloudflare/miniflare/issues/209),
thanks [@Electroid](https://github.com/Electroid).
- Return fixed time from `new Date()`/`Date.now()`, unless the
`--actual-time`/`actualTime: true` option is set, to match
[the behaviour the Workers runtime](https://developers.cloudflare.com/workers/learning/security-model/#step-1-disallow-timers-and-multi-threading).
Closes [issue #225](https://github.com/cloudflare/miniflare/issues/225),
thanks [@ItalyPaleAle](https://github.com/ItalyPaleAle).
- Add support for
[`(De)CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API).
Closes [issue #206](https://github.com/cloudflare/miniflare/issues/206),
thanks [@Electroid](https://github.com/Electroid).
- Add an interactive REPL via the `--repl` flag. Any other flag can be passed
too, and options will automatically be loaded from `wrangler.toml` files.
Specifying a script is optional when `--repl` is enabled. The REPL can also be
started programmatically via the `Miniflare#startREPL()` method. See []() for
more details. Thanks [@threepointone](https://github.com/threepointone) for
the idea over at
[cloudflare/wrangler2#1263](https://github.com/cloudflare/wrangler2/issues/1263).

### Fixes

- Load service bindings from `services` instead of `experimental_services`, and
use `binding` instead of `name` for the binding name. Thanks
[@jrencz](https://github.com/jrencz) for
[the PR](https://github.com/cloudflare/miniflare/pull/302).
[issue #280](https://github.com/cloudflare/miniflare/issues/280).
- Log warning instead of error when fetching `Request#cf` object fails. Closes
[issue #224](https://github.com/cloudflare/miniflare/issues/224), thanks
[@threepointone](https://github.com/threepointone).
- Increase the subrequest limit for `unbound` workers from 50 to 1000, and limit
the number of calls to internal APIs such as KV/Durable Object to 1000. Closes
[issue #274](https://github.com/cloudflare/miniflare/issues/274), thanks
[@isaac-mcfadyen](https://github.com/isaac-mcfadyen).
- Fix logging of accessible hosts in Node.js 18
- Remove `name` from `DurableObjectId`s in `DurableObjectState` to match the
behaviour of the Workers runtime. Closes
[issue #219](https://github.com/cloudflare/miniflare/issues/219).
- Allow failure WebSocket upgrade responses. Closes
[issue #174](https://github.com/cloudflare/miniflare/issues/174), thanks
[@jinjor](https://github.com/jinjor).
- Correctly handle internationalised domain names in routes. Closes
[issue #186](https://github.com/cloudflare/miniflare/issues/186), thanks
[@dsod](https://github.com/dsod).
- Improve the error message when Durable Object bindings are missing a script to
mention mounting. Closes
[issue #221](https://github.com/cloudflare/miniflare/issues/221), thanks
[@konsumer](https://github.com/konsumer).
- Allow WebSockets to be closed without a status code. Closes
[issue #284](https://github.com/cloudflare/miniflare/issues/284), thanks
[@hansottowirtz](https://github.com/hansottowirtz).
- Allow Durable Object alarms to be scheduled less than 30 seconds in the
future. Closes
[issue #290](https://github.com/cloudflare/miniflare/issues/290), thanks
[@wighawag](https://github.com/wighawag) and
[@CraigglesO](https://github.com/CraigglesO) for
[the PR](https://github.com/cloudflare/miniflare/pull/294).
- Fix `DurableObjectStorage#list()` when alarms are scheduled. Closes
[issue #297](https://github.com/cloudflare/miniflare/issues/297), thanks
[@evanderkoogh](https://github.com/evanderkoogh) and
[@CraigglesO](https://github.com/CraigglesO) for
[the PR](https://github.com/cloudflare/miniflare/pull/298).

## 2.5.1

### ⚠️ Security Update
Expand Down
9 changes: 8 additions & 1 deletion docs/docs-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const fs = require("fs");
const path = require("path");

const logoSVGPath = path.resolve(__dirname, "..", "miniflare.svg");
const logoSVGContent = fs.readFileSync(logoSVGPath, "utf8");

module.exports = {
product: "Miniflare",
pathPrefix: "/",
productIconKey: "docs-engine",
productIconKey: "miniflare",
logoSVGContent,
contentRepo: "cloudflare/miniflare",
contentRepoFolder: "../master/docs", // "../" removes "production/"
externalLinks: [
Expand Down
61 changes: 61 additions & 0 deletions docs/miniflare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/src/content/core/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const mf = new Miniflare({

Specifically Miniflare supports the following flags:

- [`global_navigator`/`no_global_navigator`](https://developers.cloudflare.com/workers/platform/compatibility-dates#global-navigator)
- [`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)
- [`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)
- [`formdata_parser_supports_files`/`formdata_parser_converts_files_to_strings`](https://developers.cloudflare.com/workers/platform/compatibility-dates#formdata-parsing-supports-file)
Expand Down
54 changes: 44 additions & 10 deletions docs/src/content/core/standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ Miniflare supports the following Web Standards in its sandbox:
`ReadableStreamDefaultController`, `ReadableStreamDefaultReader`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultController`, `WritableStreamDefaultWriter`,
`FixedLengthStream`
`FixedLengthStream`, `CompressionStream`, `DecompressionStream`
- **Events:** `Event`, `EventTarget`, `AbortController`, `AbortSignal`
- **Event Types:** `fetch`, `scheduled`, `unhandledrejection`,
`rejectionhandled`
- **Misc:** `structuredClone`
- **Misc:** `structuredClone`, `navigator`

## Subrequests

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

## Frozen Time

To match the
[behaviour of the Workers runtime](https://developers.cloudflare.com/workers/learning/security-model/#step-1-disallow-timers-and-multi-threading),
Miniflare will always return the time of last I/O from `new Date()` and
`Date.now()`.

This behaviour can be disabled by setting the `actualTime` option, which may be
useful for performance testing. Note that the Miniflare
[🤹 Jest Environment](/testing/jest) automatically enables this option.

import ConfigTabs from "../components/mdx/config-tabs";

<ConfigTabs>

```sh
$ miniflare --actual-time
```

```toml
---
filename: wrangler.toml
---
[miniflare]
actual_time = true
```

```js
const mf = new Miniflare({
actualTime: true,
});
```

</ConfigTabs>

## Global Functionality Limits

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

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

import ConfigTabs from "../components/mdx/config-tabs";

<ConfigTabs>

```sh
Expand Down
5 changes: 5 additions & 0 deletions docs/src/content/get-started/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ const mf = new Miniflare({
kvNamespaces: ["TEST_NAMESPACE"], // KV namespace to bind
kvPersist: "./kv-data", // Persist KV data (to optional path)

r2Buckets: ["BUCKET"], // R2 bucket to bind
r2Persist: "./r2-data", // Persist R2 data (to optional path)

durableObjects: {
// Durable Object to bind
TEST_OBJECT: "TestObject", // className
Expand Down Expand Up @@ -497,6 +500,8 @@ const waitUntil = await mf.dispatchScheduled(Date.now(), "30 * * * *");

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

const BUCKET = await mf.getR2Bucket("BUCKET");

const caches = await mf.getCaches(); // Get global `CacheStorage` instance
const defaultCache = caches.default;
const namedCache = await caches.open("name");
Expand Down
40 changes: 39 additions & 1 deletion docs/src/content/get-started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,37 @@ $ miniflare worker.js --open # Opens http://localhost:8787
$ miniflare worker.js --open https://example.com # Opens https://example.com
```

### REPL

Add the `--repl` flag to start an interactive REPL session. This behaves exactly
like the [Node.js REPL](https://nodejs.org/api/repl.html#repl), except you have
access to Workers Runtime APIs instead. Any other Miniflare flag can be used
too, with `.env`, `package.json` and `wrangler.toml` files automatically loaded.
Specifying a script is optional when `--repl` is enabled, but may be required if
you're using Durable Objects. If you're using an ES module format worker,
bindings will be accessible via the `env` global variable.

```sh
$ miniflare --repl --kv TEST_NAMESPACE
> await new HTMLRewriter().on("p", {
... element(e) {
..... e.setInnerContent("new");
..... }
... }).transform(new Response("<p>old</p>")).text()
'<p>new</p>'
> await env.TEST_NAMESPACE.put("key", "value")
undefined
> await env.TEST_NAMESPACE.get("key")
'value'
>
```
### Update Checker
The CLI includes an automatic update checker that looks for new versions of
Miniflare once a day. As Cloudflare are always improving and tweaking workers,
you should aim to install these promptly for improved compatibility with the
real workers environment. You can disable this with the `--no-update-check`
real Workers environment. You can disable this with the `--no-update-check`
flag.
## Reference
Expand All @@ -234,11 +259,13 @@ Core Options:
--modules-rule Modules import rule [array:TYPE=GLOB]
--compat-date Opt into backwards-incompatible changes from [string]
--compat-flag Control specific backwards-incompatible changes [array]
--usage-model Usage model (bundled by default) [string]
-u, --upstream URL of upstream origin [string]
-w, --watch Watch files for changes [boolean]
-d, --debug Enable debug logging [boolean]
-V, --verbose Enable verbose logging [boolean]
--(no-)update-check Enable update checker (enabled by default) [boolean]
--repl Enable interactive REPL [boolean]
--root Path to resolve files relative to [string]
--mount Mount additional named workers [array:NAME=PATH[@ENV]]
--name Name of service [string]
Expand All @@ -247,6 +274,7 @@ Core Options:
--global-timers Allow setting timers outside handlers [boolean]
--global-random Allow secure random generation outside [boolean]
handlers
--actual-time Always return correct time from Date methods [boolean]

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

R2 Options:
-r, --r2 R2 bucket to bind [array]
--r2-persist Persist R2 data (to optional path) [boolean/string]

Durable Objects Options:
-o, --do Durable Object to bind [array:NAME=CLASS[@MOUNT]]
--do-persist Persist Durable Object data (to [boolean/string]
Expand Down Expand Up @@ -323,6 +355,10 @@ kv_namespaces = [ # --kv
{ binding = "TEST_NAMESPACE", id = "", preview_id = "" }
]

r2_buckets = [ # --r2
{ binding = "BUCKET", bucket_name = "" }
]

[durable_objects]
bindings = [ # --do
{ name = "OBJECT", class_name = "Object" }
Expand Down Expand Up @@ -366,6 +402,7 @@ watch = true # --watch
live_reload = true # --live-reload
env_path = ".env.test" # --env
kv_persist = true # --kv-persist
r2_persist = true # --r2-persist
cache_persist = "./cache" # --cache-persist
cache = false # --no-cache
durable_objects_persist = true # --do-persist
Expand All @@ -375,6 +412,7 @@ cf_fetch = "./cf.json" # --cf-fetch ./cf.json
cf_fetch = false # --no-cf-fetch
https = true # --https
https = "./cert_cache" # --https ./cert_cache
actual_time = true # --actual-time
global_async_io = true # --global-async-io
global_timers = true # --global-timers
global_random = true # --global-random
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/storage/cache.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
order: 2
order: 3
---

# ✨ Cache
Expand Down
Loading

0 comments on commit d5606ec

Please sign in to comment.