medusa icon indicating copy to clipboard operation
medusa copied to clipboard

feat(workflows-sdk,orchestration): async step as background task

Open carlos-r-l-rodrigues opened this issue 10 months ago • 13 comments

What:

When a step flagged as async: true returns a new StepResponse itp will be marked as success automatically after its execution.

If it doesn't return a StepResponse instance, it is considered a regular async step that will require setStepSuccess or setStepFailure to called later.

createStep(
  {
    name: "step_background",
    async: true,
  },
  jest.fn(async (input) => {
    await setTimeout(200)

    return new StepResponse(input)
  })
)

Regular:

createStep(
  {
    name: "step_background",
    async: true,
  },
  jest.fn(async (input) => {
    await setTimeout(200)
  })
)

carlos-r-l-rodrigues avatar Mar 29 '24 18:03 carlos-r-l-rodrigues

🦋 Changeset detected

Latest commit: 8642dce9f197f2e2b5121d6a52937b7a30936a4e

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

This PR includes changesets to release 3 packages
Name Type
@medusajs/orchestration Patch
@medusajs/workflows-sdk Patch
@medusajs/workflow-engine-redis 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

changeset-bot[bot] avatar Mar 29 '24 18:03 changeset-bot[bot]

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

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 7:58am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Apr 3, 2024 7:58am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 7:58am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 7:58am

vercel[bot] avatar Mar 29 '24 18:03 vercel[bot]

/snapshot-this

carlos-r-l-rodrigues avatar Mar 29 '24 21:03 carlos-r-l-rodrigues

:rocket: A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 1a48fe0282a8bc1f8548a4736255e457d173da09

github-actions[bot] avatar Mar 29 '24 21:03 github-actions[bot]

Looks good to me, so if we return a step response, after the execution we mark it as success and we set the returned response, otherwise we expect a manual action as usual right?

Exactly 👍

srindom avatar Mar 29 '24 21:03 srindom

I am seeing this error after trying the snapshot:

CleanShot 2024-04-01 at 9  39 58

srindom avatar Apr 01 '24 07:04 srindom

/snapshot-this

srindom avatar Apr 01 '24 07:04 srindom

:rocket: A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 1a48fe0282a8bc1f8548a4736255e457d173da09

github-actions[bot] avatar Apr 01 '24 07:04 github-actions[bot]

I am seeing this error after trying the snapshot:

CleanShot 2024-04-01 at 9  39 58

Apparently your orchestration package is an old version comming from a node_modules inside modules-sdk

carlos-r-l-rodrigues avatar Apr 01 '24 09:04 carlos-r-l-rodrigues

/snapshot-this

srindom avatar Apr 01 '24 14:04 srindom

:rocket: A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 2e914a5fc588f3b32e69699427036301bada5bfd

github-actions[bot] avatar Apr 01 '24 14:04 github-actions[bot]

/snapshot-this

srindom avatar Apr 02 '24 14:04 srindom

:rocket: A snapshot release has been made for this PR

Test the snapshots by updating your package.json with the newly published versions:

yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add [email protected]
yarn add [email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]
yarn add @medusajs/[email protected]

Latest commit: 982fb44cde9ed83fcc5c8698c56e41e691e5a004

github-actions[bot] avatar Apr 02 '24 14:04 github-actions[bot]

@srindom can we merge this?

carlos-r-l-rodrigues avatar Apr 03 '24 09:04 carlos-r-l-rodrigues

Yep! Lgtm

srindom avatar Apr 03 '24 09:04 srindom