Skip to content
Draft
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
15 changes: 10 additions & 5 deletions workbench/example/workflows/99_e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1829,18 +1829,23 @@ export async function abortParallelWorkflow() {
'use workflow';

const controller = new AbortController();
const parallelSteps = Promise.all([
longStep(controller.signal),
longStep(controller.signal),
longStep(controller.signal),
]);

const result = await Promise.race([
Promise.all([
longStep(controller.signal),
longStep(controller.signal),
longStep(controller.signal),
]),
parallelSteps,
sleep('3s').then(() => 'timeout' as const),
]);

if (result === 'timeout') {
controller.abort();
// Wait for the in-flight steps to observe the abort before completing the
// workflow. Returning immediately leaves the parallel branch dangling and
// can keep the run open until the steps hit their natural 30s completion.
await parallelSteps;
return { status: 'timed out' };
}

Expand Down
Loading