medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.93k stars 2.6k forks source link

Error: Workflow with id "create-product-variants" and step definition already exists. #7105

Closed Garnett1314 closed 4 months ago

Garnett1314 commented 6 months ago

I have a problem, I was developing a custom payment plugin, plugin dependency: @medusajs/medusa. then I compiled it and passed it, so I ran npm install my custom payment plugin under my medusa BACKEND_PATH, the installation was successful, then my yarn run start reported an error: error: Error starting server Error: Workflow with id "create-product-variants" and step definition already exists. at WorkflowManager.register at WorkflowManager.register (/root/ws/node_modules/@medusajs/orchestration/dist/workflow/workflow-manager.js:36:23) at Object. (/root/medusa-payment-custom/node_modules/@medusajs/core-flows/dist/definition/product/create-product-variants .js:89:33) at Module._compile (node:internal/modules/cjs/loader:1356:14) at Module._extensions..js (node:internal/modules/cjs/loader:1414:10) at Module.load (node:internal/modules/cjs/loader:1197:32) at Module._load (node:internal/modules/cjs/loader:1013:12) at Module.require (node:internal/modules/cjs/loader:1225:19) at require (node:internal/modules/helpers:177:18) at Object. (/root/medusa-payment-custom/node_modules/@medusajs/core-flows/dist/definition/product/index.js:30:46) at Module._compile (node:internal/modules/cjs/loader:1356:14) error Command failed with exit code 1

jamcalli commented 6 months ago

I am experiencing the exact same issue. Did you manage to resolve?

nyctonio commented 6 months ago

i am also getting the same error

carlos-r-l-rodrigues commented 6 months ago

Do you mind sharing your package.json dependencies? this is very likely a version issue where 2 different definitions of the same workflow are being exported.

nyctonio commented 6 months ago
  "dependencies": {
    "@medusajs/admin": "latest",
    "@medusajs/cache-inmemory": "latest",
    "@medusajs/cache-redis": "latest",
    "@medusajs/event-bus-local": "latest",
    "@medusajs/event-bus-redis": "latest",
    "@medusajs/file-local": "latest",
    "@medusajs/medusa": "latest",
    "@tanstack/react-query": "4.22.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "16.3.1",
    "express": "^4.17.2",
    "medusa-fulfillment-manual": "latest",
    "medusa-interfaces": "latest",
    "medusa-payment-manual": "latest",
    "medusa-payment-stripe": "latest",
    "prism-react-renderer": "^2.0.4",
    "typeorm": "^0.3.16"
  },
  "devDependencies": {
    "@babel/cli": "^7.14.3",
    "@babel/core": "^7.14.3",
    "@babel/preset-typescript": "^7.21.4",
    "@medusajs/medusa-cli": "latest",
    "@stdlib/number-float64-base-normalize": "0.0.8",
    "@types/express": "^4.17.13",
    "@types/jest": "^27.4.0",
    "@types/node": "^17.0.8",
    "babel-preset-medusa-package": "^1.1.19",
    "cross-env": "^7.0.3",
    "eslint": "^6.8.0",
    "jest": "^27.3.1",
    "rimraf": "^3.0.2",
    "ts-jest": "^27.0.7",
    "ts-loader": "^9.2.6",
    "typescript": "^4.5.2",
    "@types/mime": "1.3.5"
  },
carlos-r-l-rodrigues commented 6 months ago

did you try removing your node_modules folder, yarn.lock file and reinstalling it again?

nyctonio commented 6 months ago

nope it didn't help

jamcalli commented 6 months ago

I was able to resolve my issue. I was spacing on running dev specifying the preserve symlinks.

npm run dev -- -- --preserve-symlinks

This made my error go away. When running just npm run dev I get the same error.

carlos-r-l-rodrigues commented 6 months ago

@nyctonio could you please try that again using the lastest (1.20.5) version?

dtduong30 commented 6 months ago

@nyctonio could you please try that again using the lastest (1.20.5) version?

Are you suggesting upgrading @medusajs/medusa to version 1.20.5 in the package.json?

carlos-r-l-rodrigues commented 6 months ago

Are you suggesting upgrading @medusajs/medusa to version 1.20.5 in the package.json

any version from 1.20.5 and beyond. at the time of writing the latest was it. it should not throw this error anymore

pepijn-vanvlaanderen commented 5 months ago

Looks like this issue still happens in v1.20.6 when you try to develop a plugin locally with npm link. Then it will throw Error: Workflow with id create-api-keys already registered.

Also mentioned by another user in Discord: https://discord.com/channels/876835651130097704/1245573998431965235/1245573998431965235

pepijn-vanvlaanderen commented 5 months ago

Was reading an earlier comment passing --preserve-symlinks, that actually did the trick. For yarn this is: yarn dev -- --preserve-symlinks

sradevski commented 4 months ago

Closing this since there is a solution suggested for it. We might revisit if the issue persists closer to our full release of v2