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
9 changes: 9 additions & 0 deletions .changeset/miniflare-v8-flags-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"miniflare": minor
---

Support passing V8 flags to `workerd` via the `MINIFLARE_WORKERD_V8_FLAGS` environment variable

The generated `workerd` config already supports `v8Flags`, but Miniflare never populated it, so the runtime always ran with V8's default heap limit (~1.4 GB). Large dev applications (e.g. big SSR module graphs under `@cloudflare/vite-plugin`, where each server-file edit grows the runner isolate's heap) can reach that limit, at which point `workerd` aborts with `V8 fatal error; location = Reached heap limit` and every subsequent `dispatchFetch()` fails with `fetch failed` until the dev server is manually restarted.

Setting e.g. `MINIFLARE_WORKERD_V8_FLAGS="--max-old-space-size=4096"` raises the limit and keeps long dev sessions alive. The variable follows the same space-separated format as `MINIFLARE_WORKERD_AUTOGATES`.
3 changes: 3 additions & 0 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,9 @@ export class Miniflare {
autogates: process.env.MINIFLARE_WORKERD_AUTOGATES
? process.env.MINIFLARE_WORKERD_AUTOGATES.split(" ")
: [],
v8Flags: process.env.MINIFLARE_WORKERD_V8_FLAGS
? process.env.MINIFLARE_WORKERD_V8_FLAGS.split(" ")
: [],
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/miniflare/types/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ declare namespace NodeJS {
MINIFLARE_WORKERD_CONFIG_DEBUG?: string;
MINIFLARE_ASSERT_BODIES_CONSUMED?: "true";
MINIFLARE_WORKERD_AUTOGATES?: string;
MINIFLARE_WORKERD_V8_FLAGS?: string;
}
}
Loading