no-non-serializable-step-return - ESLint plugin rules

This rule disallows non-serializable values, such as Map, Set, WeakMap, and WeakSet, inside new StepResponse(...) or new WorkflowResponse(...).

Severity#

error. This rule is enabled in the strict preset.

By default, Medusa projects use the recommended preset, which doesn't enable this rule. To use it, switch to the strict preset.

What it Targets#

This rule targets files in your project's src/workflows directory. It reports values passed to new StepResponse(...) or new WorkflowResponse(...) that contain a Map, Set, WeakMap, or WeakSet.

The following code is reported by the rule:

src/workflows/example.ts
1import { 2  createStep,3  StepResponse,4} from "@medusajs/framework/workflows-sdk"5
6const step1 = createStep(7  "step-1",8  (input, { container }) => {9    const myMap = new Map()10
11    // ...12
13    return new StepResponse({14      myMap,15    })16  }17)

Instead, return a plain object or array:

src/workflows/example.ts
1import { 2  createStep,3  StepResponse,4} from "@medusajs/framework/workflows-sdk"5
6const step1 = createStep(7  "step-1",8  (input, { container }) => {9    const myMap = {10      key: "value",11    }12
13    // ...14
15    return new StepResponse({16      myMap,17    })18  }19)

Why it's Important#

A step or workflow response must be serializable so the workflow engine can persist and pass it between steps. Values like Map and Set don't serialize to plain data and are lost. Use a plain object or array instead.

Learn more in the Workflow Constraints documentation.

Fixable#

This rule isn't auto-fixable.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵