Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/guides/workflow/creating-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export function main(args) {
});

return {
success: true,
orderId: validated.id,
paymentId: payment.id,
};
Expand Down Expand Up @@ -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}`);
}
Expand Down
24 changes: 24 additions & 0 deletions docs/guides/workflow/monitoring-executions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment thread
k1LoW marked this conversation as resolved.
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:
Expand Down
1 change: 0 additions & 1 deletion docs/guides/workflow/triggering-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export async function main(args) {
console.log("Notification workflow started:", executionId);

return {
success: true,
notificationExecutionId: executionId,
};
}
Expand Down
Loading