Does worklows have any special consideration for `waitForEvent` in terms of promises? I have seen

Does worklows have any special consideration for
waitForEvent
in terms of promises?


I have seen examples using a
Promise.race
like
let value = Promise.race([
  step.waitForEvent("payment success", { type: "payment-success-webhook", timeout: "4 hours" ),
  step.waitForEvent("payment failure", { type: "payment-failure-webhook", timeout: "4 hours" ),
])


So before testing... Wondering if a
Promise.all
would also work? 🤔

const longArray: { id: string, data: any }[] = [
  /* imagine a lot of things here */ 
  ...
]

const bunchOfWaitForEvnts = longArray.map(item => step.waitForEvent("sub-workflow", { type: `id-${item.id}`, timeout: "4 hours" ))
const aggregatedResponses = Promise.all(bunchOfWaitForEvnts)

await step.do('do-more-stuff-with-aggregated-responses', async () => { /* */})


I'm trying to simplify some flows. Like:
  • if I could wait for 20 events based on
    bunchOfWaitForEvnts
  • Trigger 20 workflows based on
    bunchOfWaitForEvnts
  • Each workflow calls
    instance.sendEvent()
    with their ID.
    Then it occurred to me that this could also help with the sub-request limit? 🤔
Was this page helpful?