Skip to content

Commit 82a8b0f

Browse files
authored
docs(workflow): document tailor.workflow.resumeWorkflow (#155)
* docs(workflow): document tailor.workflow.resumeWorkflow The SDK now exposes `tailor.workflow.resumeWorkflow(executionId)` so user code can resume a failed or pending-retry execution directly (tailor-platform/sdk#1608). The workflow guides only covered the `tailor-sdk workflow resume` CLI command, leaving self-healing flows (functions, executors, pipeline resolvers) with no in-code path to point readers at. Add a "Resuming from Code" subsection to the monitoring guide covering the API, its return value, and the error it rejects with. * docs(workflow): return results directly in workflow samples Review the workflow guide samples for the same result-object smell fixed in the IdP guide. The `tailor.workflow.*` runtime calls reject on failure, so wrapping their results in `{ success: true }` (and, in the resumeWorkflow example, catching to return `{ success: false }`) made the samples read as if they presuppose try/catch-based error handling. Drop the redundant `success` field from the triggerWorkflow, multi-step, and error-handling samples, and rewrite the resumeWorkflow example to let the error propagate. Keep the one try/catch that re-throws a wrapped message, since controlling the error message is the case where catching is warranted. * docs(workflow): clarify resumeWorkflow example and resume semantics Apply Copilot review feedback on the Resuming from Code section. - Use `args.executionId` in the example so it matches the `resumeWorkflow(executionId)` signature and the `executionId` term used elsewhere in the guide. - Reword the behavior paragraph to match the "restart from main, reuse cached results" mechanics described earlier in the section, rather than the looser "resumes from the point of failure" phrasing. * docs(workflow): mention pending-retry in Resuming from Code intro Apply Copilot review feedback. The intro said "a failed execution" while the API reference below and the SDK changeset both cover "failed or pending-retry" executions, so widen the intro to match and avoid implying resumeWorkflow cannot resume pending-retry executions.
1 parent 876c9f0 commit 82a8b0f

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

docs/guides/workflow/creating-workflows.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ export function main(args) {
189189
});
190190

191191
return {
192-
success: true,
193192
orderId: validated.id,
194193
paymentId: payment.id,
195194
};
@@ -239,7 +238,7 @@ export function main(args) {
239238
try {
240239
// Risky operation
241240
const result = performOperation();
242-
return { success: true, result };
241+
return { result };
243242
} catch (error) {
244243
throw new Error(`Operation failed: ${error.message}`);
245244
}

docs/guides/workflow/monitoring-executions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,30 @@ processData → Skipped (cached)
204204
saveToDb → Executed again
205205
```
206206

207+
### Resuming from Code
208+
209+
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.
210+
211+
**Example:**
212+
213+
```javascript
214+
export async function main(args) {
215+
const resumedId = await tailor.workflow.resumeWorkflow(args.executionId);
216+
console.log("Resumed execution:", resumedId);
217+
return { resumedExecutionId: resumedId };
218+
}
219+
```
220+
221+
**API Reference:**
222+
223+
- **First argument**: Execution ID of a failed or pending-retry execution (string)
224+
225+
**Return value:**
226+
227+
- Execution ID of the resumed execution (string)
228+
229+
`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.
230+
207231
### When to Use Resume
208232

209233
Resume is useful when:

docs/guides/workflow/triggering-workflow.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export async function main(args) {
3232
console.log("Notification workflow started:", executionId);
3333

3434
return {
35-
success: true,
3635
notificationExecutionId: executionId,
3736
};
3837
}

0 commit comments

Comments
 (0)