medusa icon indicating copy to clipboard operation
medusa copied to clipboard

[Bug]: Error: Workflow with id \"create-fulfillment-workflow\" and step definition already exists.

Open ashcochrane opened this issue 9 months ago • 42 comments

Package.json file

{
  "name": "engage-ecommerce-api",
  "version": "0.0.1",
  "description": "A starter for Medusa projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "debug": "DEBUG=medusa-core-utils:workflow,medusa:* medusa develop",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"
  },
  "dependencies": {
    "@medusajs/admin-sdk": "2.3.1",
    "@medusajs/cli": "2.3.1",
    "@medusajs/framework": "2.3.1",
    "@medusajs/medusa": "2.3.1",
    "@mikro-orm/core": "5.9.7",
    "@mikro-orm/knex": "5.9.7",
    "@mikro-orm/migrations": "5.9.7",
    "@mikro-orm/postgresql": "5.9.7",
    "awilix": "^8.0.1",
    "multer": "^1.4.5-lts.1",
    "pg": "^8.13.0",
    "ulid": "^2.3.0",
    "zod": "3.22.4"
  },
  "devDependencies": {
    "@ashtoncochrane/types": "0.0.4",
    "@medusajs/test-utils": "2.3.1",
    "@mikro-orm/cli": "5.9.7",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/jest": "^29.5.13",
    "@types/multer": "^1",
    "@types/node": "^20.0.0",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.2.25",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.6.2",
    "vite": "^5.2.11"
  },
  "engines": {
    "node": ">=20"
  },
  "packageManager": "[email protected]"
}

Node.js version

v22.6.0

Database and its version

PostgreSQL 16

Operating system name and version

MacOS 13.4 although deploying into node:22-slim docker container

Browser name

No response

What happended?

When attempting to run yarn start an error around step definitions already existing is being thrown. We havent touched anything to do with fulfillments nor created any workflow/step that has the create-fulfillment-workflow id. Is it potentially registering the create-fulfillment-workflow twice?

It seems to be happening when RoutesLoader in medusa/packages/src/loader.ts is being called. I console.logged the inputs being provided to this that caused the error and they are the following:

app:  app #  object, can provide more details if needed.
sourcePaths: ['/app/.medusa/server/src/api','/app/.medusa/server/node_modules/@medusajs/medusa/dist/api']
restrictedFields?.store: [ 'order', 'orders' ]

Expected behavior

Expect API to start successfully

Actual behavior

Error being thrown:

engage-ecommerce-api  | {"level":"error","message":"An error occurred while registering API Routes. Error: Workflow with id \"create-fulfillment-workflow\" and step definition already exists.","stack":[{"columnNumber":15,"fileName":"/app/.medusa/server/node_modules/@medusajs/medusa/dist/loaders/api.js","functionName":"exports.default","lineNumber":60,"methodName":"default","native":false,"typeName":"exports"},{"columnNumber":3,"fileName":"/app/.medusa/server/node_modules/@medusajs/medusa/src/loaders/index.ts","functionName":"async loadEntrypoints","lineNumber":111,"methodName":null,"native":false,"typeName":null},{"columnNumber":31,"fileName":"/app/.medusa/server/node_modules/@medusajs/medusa/src/loaders/index.ts","functionName":"async exports.default","lineNumber":170,"methodName":"default","native":false,"typeName":"async exports"},{"columnNumber":59,"fileName":"/app/.medusa/server/node_modules/@medusajs/medusa/src/commands/start.ts","functionName":"async internalStart","lineNumber":169,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"/app/.medusa/server/node_modules/@medusajs/medusa/src/commands/start.ts","functionName":"async start","lineNumber":293,"methodName":null,"native":false,"typeName":null}],"timestamp":"2025-01-24 12:04:36"}

Link to reproduction repo

N/A - Can give access to repo if needed

ashcochrane avatar Jan 24 '25 12:01 ashcochrane