context.run
context.run
function for each stepcontext.run
only serves to connect stepsresult
will be unitialized when the endpoint is called again to run step-2
.
If you are curious about why an endpoint is called multiple times, see how Workflow works.
context.run
Failed to authenticate Workflow request.
errors. This can happen if you return
based on the result of the non-idempotent code before any workflow step.
To prevent this, ensure that the non-idempotent code (such as getResultFromDb
in the example) runs within context.run
.
context.run
someWork
function must be idempotent:
someWork
executes once and makes a change to a database. However, before the database had a chance to respond with the successful change, the connection is lost. Your Workflow cannot know if the database change was successful or not. The caller has no choice but to retry, which will cause someWork
to run twice.
If someWork
is not idempotent, this could lead to unintended consequences. For example duplicated records or corrupted data. Idempotency is crucial to maintaining the integrity and reliability of your workflow.
context.call
, context.sleep
, context.sleepFor
, or context.run
within another context.run
.
context.run
. If no steps are defined, the workflow will throw a Failed to authenticate Workflow request.
error.
Promise.all
to run steps in parallel. However, a similar method, Promise.any
, is not supported for workflow steps.
While Promise.all
works seamlessly, Promise.any
does not currently function with workflow steps. We are exploring the possibility of adding support for Promise.any
in the future.
If you have a specific use case that requires Promise.any
, don’t hesitate to reach out to Upstash support.