Skip to content

Commit a52b78a

Browse files
committed
refactor: remove rollbackAll from public API, add RollbackConfig to instance options
- Remove step.rollbackAll() from WorkflowStep (now internal to engine) - Remove RollbackAllOptions type (no longer public) - Add RollbackConfig type for auto-rollback configuration - Add rollback option to WorkflowInstanceCreateOptions Rollback is now triggered automatically when workflow throws and rollback config is enabled at instance creation.
1 parent 1dc273a commit a52b78a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

types/defines/rpc.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ declare namespace CloudflareWorkersModule {
321321
undoConfig?: WorkflowStepConfig;
322322
};
323323

324-
export type RollbackAllOptions = {
325-
/** If true, continue executing remaining undos after a failure and throw AggregateError at end. Default: false */
326-
continueOnError?: boolean;
327-
};
328-
329324
export abstract class WorkflowStep {
330325
do<T extends Rpc.Serializable<T>>(
331326
name: string,
@@ -350,7 +345,6 @@ declare namespace CloudflareWorkersModule {
350345
handler: RollbackHandler<T>,
351346
config?: RollbackStepConfig
352347
): Promise<T>;
353-
rollbackAll(error?: unknown, options?: RollbackAllOptions): Promise<void>;
354348
}
355349

356350
export abstract class WorkflowEntrypoint<

types/defines/workflows.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ type WorkflowSleepDuration =
5151

5252
type WorkflowRetentionDuration = WorkflowSleepDuration;
5353

54+
type RollbackConfig = {
55+
/** If true, continue executing remaining undos after undo failure. Default: false */
56+
continueOnError?: boolean;
57+
};
58+
5459
interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
5560
/**
5661
* An id for your Workflow instance. Must be unique within the Workflow.
@@ -68,6 +73,11 @@ interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
6873
successRetention?: WorkflowRetentionDuration;
6974
errorRetention?: WorkflowRetentionDuration;
7075
};
76+
/**
77+
* Enable automatic rollback on uncaught workflow errors.
78+
* When enabled, registered undo handlers execute in LIFO order when the workflow throws.
79+
*/
80+
rollback?: RollbackConfig;
7181
}
7282

7383
type InstanceStatus = {

0 commit comments

Comments
 (0)