diff --git a/docs/guides/workflow/creating-workflows.md b/docs/guides/workflow/creating-workflows.md index b1a01c1..ab1a3db 100644 --- a/docs/guides/workflow/creating-workflows.md +++ b/docs/guides/workflow/creating-workflows.md @@ -189,7 +189,6 @@ export function main(args) { }); return { - success: true, orderId: validated.id, paymentId: payment.id, }; @@ -239,7 +238,7 @@ export function main(args) { try { // Risky operation const result = performOperation(); - return { success: true, result }; + return { result }; } catch (error) { throw new Error(`Operation failed: ${error.message}`); } diff --git a/docs/guides/workflow/monitoring-executions.md b/docs/guides/workflow/monitoring-executions.md index 0ada154..a0ad561 100644 --- a/docs/guides/workflow/monitoring-executions.md +++ b/docs/guides/workflow/monitoring-executions.md @@ -204,6 +204,30 @@ processData → Skipped (cached) saveToDb → Executed again ``` +### Resuming from Code + +You can also resume a failed or pending-retry execution from your own code (a workflow job function, an executor, or a pipeline resolver) using `tailor.workflow.resumeWorkflow()`. This lets you build self-healing flows that recover from transient failures automatically, without an operator running `tailor-sdk workflow resume` or using the Tailor Console. + +**Example:** + +```javascript +export async function main(args) { + const resumedId = await tailor.workflow.resumeWorkflow(args.executionId); + console.log("Resumed execution:", resumedId); + return { resumedExecutionId: resumedId }; +} +``` + +**API Reference:** + +- **First argument**: Execution ID of a failed or pending-retry execution (string) + +**Return value:** + +- Execution ID of the resumed execution (string) + +`resumeWorkflow()` behaves like the `resume` command described above. The workflow restarts from the main function and reuses the cached results of successful job functions, so only failed or not-yet-executed jobs run again. It rejects with an error whose message is prefixed with `resumeWorkflow failed:` when the execution cannot be resumed. Let that error propagate to fail the calling execution, and add a `try`/`catch` only when you need to control the error or its message. + ### When to Use Resume Resume is useful when: diff --git a/docs/guides/workflow/triggering-workflow.md b/docs/guides/workflow/triggering-workflow.md index 885d8bc..cab816c 100644 --- a/docs/guides/workflow/triggering-workflow.md +++ b/docs/guides/workflow/triggering-workflow.md @@ -32,7 +32,6 @@ export async function main(args) { console.log("Notification workflow started:", executionId); return { - success: true, notificationExecutionId: executionId, }; }