Skip to content

Commit ebf4b24

Browse files
authored
[miniflare] Deduplicate Workflow compatibility flags (#13932)
1 parent ae047ee commit ebf4b24

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

.changeset/silent-workflows-tap.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"miniflare": patch
3+
"wrangler": patch
4+
---
5+
6+
Fix local Workflow startup when compatibility flags include `experimental`
7+
8+
Miniflare now deduplicates compatibility flags for the internal Workflow engine service. This prevents `wrangler dev` from failing with `Compatibility flag specified multiple times: experimental` when the user's Worker already enables that flag.

packages/miniflare/src/plugins/workflows/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ export const WORKFLOWS_PLUGIN: Plugin<
119119
),
120120
worker: {
121121
compatibilityDate: "2024-10-22",
122-
compatibilityFlags: [
123-
"experimental",
124-
...(workflow.compatibilityFlags ?? []),
125-
],
122+
compatibilityFlags: Array.from(
123+
new Set(["experimental", ...(workflow.compatibilityFlags ?? [])])
124+
),
126125
modules: [
127126
{
128127
name: "workflows.mjs",

packages/miniflare/test/plugins/workflows/index.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@ export class MyWorkflow extends WorkflowEntrypoint {
2222
},
2323
};`;
2424

25+
test("starts Workflows with user-provided experimental compatibility flag", async ({
26+
expect,
27+
}) => {
28+
const tmp = await useTmp();
29+
const mf = new Miniflare({
30+
name: "workflow-compatibility-flags-worker",
31+
compatibilityDate: "2024-11-20",
32+
modules: true,
33+
script: WORKFLOW_SCRIPT(),
34+
workflows: {
35+
MY_WORKFLOW: {
36+
className: "MyWorkflow",
37+
name: "MY_WORKFLOW",
38+
compatibilityFlags: [
39+
"nodejs_compat",
40+
"experimental",
41+
"enhanced_error_serialization",
42+
],
43+
},
44+
},
45+
workflowsPersist: tmp,
46+
});
47+
useDispose(mf);
48+
49+
const res = await mf.dispatchFetch("http://localhost");
50+
expect(await res.text()).toBe(
51+
'{"status":"complete","__LOCAL_DEV_STEP_OUTPUTS":["yes you are"],"output":"I\'m a output string"}'
52+
);
53+
});
54+
2555
test("persists Workflow data on file-system between runs", async ({
2656
expect,
2757
}) => {

0 commit comments

Comments
 (0)