Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workflows-sdk): name for when/then step #10459

Merged
merged 9 commits into from
Dec 5, 2024

Conversation

carlos-r-l-rodrigues
Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues commented Dec 5, 2024

What:

when/then composition creates a step with a random name (ulid) under the hood when the then function is not returning a step. This is causing multiple Medusa instances fail to continue the execution of async flows because the step name will differ on each instance.

This PR removes the creation of a step if the when/then doesn't return anything, and it introduces the name parameter when creating a when/then that will return a value different than a step.

createWorkflow("wf-when", function (input) {
  step1()
  const subWorkflowRes = when("sub-flow", { input }, ({ input }) => {
    return input.callSubFlow
  }).then(() => {
    const res = subWorkflow.runAsStep({
      input: "hi from outside",
    })

    // The return is an object
    return {
      result: res,
    }
  })

  return new WorkflowResponse(step3(subWorkflowRes.result))
})

Some other fixes were applied to execute the same workflow in parallel.

FIXES: FRMW-2824

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 5:23pm
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 5:23pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 5:23pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 5:23pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 5:23pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 5:23pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 5:23pm

Copy link

changeset-bot bot commented Dec 5, 2024

🦋 Changeset detected

Latest commit: a34735b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 65 packages
Name Type
@medusajs/workflow-engine-redis Patch
@medusajs/workflows-sdk Patch
@medusajs/core-flows Patch
@medusajs/utils Patch
integration-tests-http Patch
@medusajs/cli Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/medusa-oas-cli Patch
@medusajs/oas-github-ci Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, were these the only steps we needed to change to not have the warning for our core workflows?

@carlos-r-l-rodrigues
Copy link
Contributor Author

LGTM, were these the only steps we needed to change to not have the warning for our core workflows?

Yes, only these 2.

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@carlos-r-l-rodrigues carlos-r-l-rodrigues merged commit 90ae187 into develop Dec 5, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants