Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/consolidate-miniflare-persist-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"miniflare": major
---

Consolidate persistence and temporary directory options

The per-resource persistence options (`kvPersist`, `r2Persist`, `d1Persist`, `cachePersist`, `durableObjectsPersist`, `workflowsPersist`, `secretsStorePersist`, `analyticsEngineDatasetsPersist`, `streamPersist`, `imagesPersist`, and `helloWorldPersist`) have been removed, along with `defaultPersistRoot` and `defaultProjectTmpPath`. Persistence is now configured with two options:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is resourcePersistencePath and resourceTmpPath behave just like defaultPersistRoot and defaultProjectTmpPath? If yes, it might help to say they are renamed instead.


```js
new Miniflare({
resourcePersistencePath: ".wrangler/state/v3",
resourceTmpPath: ".wrangler/tmp",
});
```

When `resourcePersistencePath` is set, each resource persists to a subdirectory named after its plugin (e.g. `.wrangler/state/v3/kv`). When it is omitted, resources are ephemeral and their data is cleared on dispose. The `boolean`, `memory:`, `file:` and relative-path forms of the old per-resource options, the `.mf` default directory, and the `Miniflare.unsafeGetPersistPaths()` method have also been removed.
7 changes: 7 additions & 0 deletions .changeset/drop-cache-warn-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"miniflare": major
---

Remove the `cacheWarnUsage` option

The `cacheWarnUsage` Worker option, which logged a warning when cache operations were used, has been removed.
5 changes: 5 additions & 0 deletions .changeset/drop-fetch-mock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"miniflare": major
---

Remove the `fetchMock` option and `createFetchMock` export
7 changes: 7 additions & 0 deletions .changeset/drop-https-key-cert-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"miniflare": major
---

Remove the `httpsKeyPath` and `httpsCertPath` options

The `httpsKeyPath` and `httpsCertPath` options have been removed. To use a custom certificate, read the files and pass their contents via the existing `httpsKey` and `httpsCert` options.
9 changes: 9 additions & 0 deletions .changeset/drop-runtime-stdio-and-structured-logs-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"miniflare": major
---

Only support structured workerd logs

The `handleRuntimeStdio` option (for handling the raw `workerd` stdout/stderr streams) and the `structuredWorkerdLogs` option (for toggling structured `workerd` logs) have been removed. Structured logging is now always enabled.

To receive `workerd`'s output, use `handleStructuredLogs`, which is passed parsed structured log entries. When no `handleStructuredLogs` handler is provided, logs are written to the console by default (`warn`/`error` to stderr, everything else to stdout).
7 changes: 7 additions & 0 deletions .changeset/drop-unsafe-sticky-blobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"miniflare": major
---

Drop the `unsafeStickyBlobs` option

This prevented blob files from being deleted when overwriting or deleting keys, and only existed to support the Durable Object isolated storage feature in `@cloudflare/vitest-pool-workers`, which was removed in 0.13.0. Blobs are now always cleaned up as expected.
5 changes: 5 additions & 0 deletions .changeset/drop-wrapped-bindings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"miniflare": major
---

Remove the `wrappedBindings` option
16 changes: 16 additions & 0 deletions .changeset/miniflare-container-engine-shared-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"miniflare": major
---

Move `containerEngine` from a per-worker option to a top-level option

`containerEngine` is now a top-level Miniflare option rather than a per-worker option, reflecting that it configures a single container engine for the whole Miniflare instance.

```js
new Miniflare({
containerEngine: "unix:///var/run/docker.sock",
workers: [{ name: "my-worker", script: "..." }],
});
```

Previously it was set inside each worker's options.
7 changes: 7 additions & 0 deletions .changeset/rename-cache-option-to-cache-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"miniflare": major
---

Rename the `cache` Worker option to `cacheAPI`

The boolean option controlling whether the Cache API caches anything has been renamed from `cache` to `cacheAPI`. This is to distinguish it from Workers Cache.
7 changes: 7 additions & 0 deletions .changeset/vitest-pool-drop-sticky-blobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/vitest-pool-workers": patch
---

Stop enabling Miniflare's removed `unsafeStickyBlobs` option

The pool no longer sets the `unsafeStickyBlobs` Miniflare option, which has been removed. This option was only needed for the Durable Object isolated storage feature that was dropped in 0.13.0, so there is no change in behaviour.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": minor
---

Remove `containerEngine` from the worker options returned by `unstable_getMiniflareWorkerOptions`

`unstable_getMiniflareWorkerOptions` no longer includes `containerEngine` in the returned `workerOptions`, since the container engine is a Miniflare instance-wide setting rather than a per-worker one. Callers that build a Miniflare instance from these options should set `containerEngine` at the top level instead.
12 changes: 3 additions & 9 deletions fixtures/unsafe-external-plugin/src/plugins/unsafe-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,15 @@ export const UNSAFE_SERVICE_PLUGIN: Plugin<
options?.map((binding) => [binding.name, new ProxyNodeBinding()]) ?? []
);
},
async getServices({
options,
tmpPath,
defaultPersistRoot,
unsafeStickyBlobs,
}) {
async getServices({ options, tmpPath, resourcePersistencePath }) {
if (!options || options.length === 0) {
return [];
}

const persistPath = getPersistPath(
UNSAFE_PLUGIN_NAME,
tmpPath,
defaultPersistRoot,
undefined
resourcePersistencePath
);

await fs.mkdir(persistPath, { recursive: true });
Expand Down Expand Up @@ -110,7 +104,7 @@ export const UNSAFE_SERVICE_PLUGIN: Plugin<
name: SharedBindings.MAYBE_SERVICE_LOOPBACK,
service: { name: SERVICE_LOOPBACK },
},
...getMiniflareObjectBindings(unsafeStickyBlobs),
...getMiniflareObjectBindings(),
],
},
} satisfies Service;
Expand Down
1 change: 1 addition & 0 deletions packages/miniflare/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const localExplorerWorkerPath = path.join(
*/
const fixtureBuilds = [
path.join(pkgRoot, "test/fixtures/unsafe-plugin/index.ts"),
path.join(pkgRoot, "test/fixtures/echo-plugin/index.ts"),
];

/**
Expand Down
21 changes: 3 additions & 18 deletions packages/miniflare/src/http/server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import fs from "node:fs/promises";
import { CERT, KEY } from "./cert";
import type { CORE_PLUGIN } from "../plugins";
import type { HttpOptions, Socket_Https } from "../runtime";
import type { Awaitable } from "../workers";
import type { z } from "zod";

export async function getEntrySocketHttpOptions(
Expand All @@ -11,15 +9,9 @@ export async function getEntrySocketHttpOptions(
let privateKey: string | undefined = undefined;
let certificateChain: string | undefined = undefined;

if (
(coreOpts.httpsKey || coreOpts.httpsKeyPath) &&
(coreOpts.httpsCert || coreOpts.httpsCertPath)
) {
privateKey = await valueOrFile(coreOpts.httpsKey, coreOpts.httpsKeyPath);
certificateChain = await valueOrFile(
coreOpts.httpsCert,
coreOpts.httpsCertPath
);
if (coreOpts.httpsKey && coreOpts.httpsCert) {
privateKey = coreOpts.httpsKey;
certificateChain = coreOpts.httpsCert;
} else if (coreOpts.https) {
privateKey = KEY;
certificateChain = CERT;
Expand All @@ -40,10 +32,3 @@ export async function getEntrySocketHttpOptions(
return { http: {} };
}
}

function valueOrFile(
value?: string,
filePath?: string
): Awaitable<string | undefined> {
return value ?? (filePath && fs.readFile(filePath, "utf8"));
}
Loading
Loading