- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
permanentFailure
Creates a StepResponse that indicates that the step has failed and the retry mechanism should not kick in anymore.
Example#
1import { Product } from "@medusajs/medusa"2import {3 createStep,4 StepResponse,5 createWorkflow6} from "@medusajs/workflows-sdk"7 8interface CreateProductInput {9 title: string10}11 12export const createProductStep = createStep(13 "createProductStep",14 async function (15 input: CreateProductInput,16 context17 ) {18 const productService = context.container.resolve(19 "productService"20 )21 22 try {23 const product = await productService.createProducts(input)24 return new StepResponse({25 product26 }, {27 product_id: product.id28 })29 } catch (e) {30 return StepResponse.permanentFailure(`Couldn't create the product: ${e}`)31 }32 }33)34 35interface WorkflowInput {36 title: string37}38 39const myWorkflow = createWorkflow<40 WorkflowInput,41 Product42 >("my-workflow", (input) => {43 // Everything here will be executed and resolved later44 // during the execution. Including the data access.45 46 const product = createProductStep(input)47 }48)49 50myWorkflow()51 .run({52 input: {53 title: "Shirt"54 }55 })56 .then(({ errors, result }) => {57 if (errors.length) {58 errors.forEach((err) => {59 if (typeof err.error === "object" && "message" in err.error) {60 console.error(err.error.message)61 } else {62 console.error(err.error)63 }64 })65 }66 console.log(result)67 })
Parameters#
message
stringAn optional message to be logged.
Default: "Permanent failure"
compensateInput
unknownOptionalReturns#
never
neverCreates a StepResponse that indicates that the step has failed and the retry mechanism should not kick in anymore.
Was this page helpful?