Terminates a flow by sending an interrupt signal. The interrupt activity can target the current flow (self-interrupt) or any other flow by its job ID (remote interrupt). Interrupted jobs have their status set to a value less than -100,000,000, indicating abnormal termination.

When no target is specified, the activity interrupts the current flow. The flow terminates immediately after this activity executes. Use conditional transitions to route to an interrupt only when needed.

app:
id: myapp
version: '1'
graphs:
- subscribes: validation.check
expire: 120

activities:
t1:
type: trigger

validate:
type: worker
topic: validate.input

cancel:
type: interrupt
reason: 'Validation failed'
throw: true
code: 410
job:
maps:
cancelled_at: '{$self.output.metadata.ac}'

proceed:
type: hook

transitions:
t1:
- to: validate
validate:
- to: cancel
conditions:
code: 422 # interrupt only on validation failure
- to: proceed

When target is specified, the activity interrupts another flow while the current flow continues to transition to adjacent activities.

app:
id: myapp
version: '1'
graphs:
- subscribes: parent.flow
expire: 120

activities:
t1:
type: trigger
job:
maps:
childJobId: '{$self.output.data.childJobId}'

stop_child:
type: interrupt
topic: child.flow.topic # topic of the target flow
target: '{t1.output.data.childJobId}'
throw: false # do not throw (silent cancellation)
descend: true # also interrupt descendant sub-flows
job:
maps:
interrupted: true

done:
type: hook

transitions:
t1:
- to: stop_child
stop_child:
- to: done
Property Type Default Description
target string (current job) Job ID to interrupt. Supports @pipe expressions.
topic string (current topic) Topic of the target flow
reason string 'Job Interrupted' Error message attached to the interruption
throw boolean true Whether to throw a JobInterrupted error
descend boolean false Whether to cascade to child/descendant flows
code number 410 Error code attached to the interruption
stack string Optional stack trace
  • Self-interrupt (no target): Category C. Verifies entry, maps job data, sets status to -1, and fires the interrupt. No children.
  • Remote interrupt (with target): Category B. Fires the interrupt best-effort, then uses executeLeg1StepProtocol to transition to adjacent activities.

InterruptActivity for the TypeScript interface

Hierarchy (view full)

Constructors

Properties

adjacencyList: StreamData[]
adjacentIndex: number = 0
code: number = 200
context: JobState
guidLedger: number = 0
logger: ILogger
status: StreamStatus = StreamStatus.SUCCESS

Methods

  • if the job is created/deleted/created with the same key, the 'gid' ensures no stale messages (such as sleep delays) enter the workstream. Any message with a mismatched gid belongs to a prior job and can safely be ignored/dropped.

    Parameters

    • jobGID: string
    • OptionalmsgGID: string

    Returns void

  • unhandled activity errors (activities that return an ERROR StreamMessage status and have no adjacent children to transition to) are bound to the job

    Parameters

    • data: Record<string, unknown>

    Returns void

  • Executes the 3-step Leg1 protocol for Category B activities (Leg1-only with children, e.g., Hook passthrough, Signal, Interrupt-another). Uses the incoming Leg1 message GUID as the GUID ledger key.

    Step A: setState + notarizeLeg1Completion + step1 markers (transaction 1) Step B: publish children + step2 markers + setStatusAndCollateGuid (transaction 2) Step C: if edge → runJobCompletionTasks + step3 markers + finalize (transaction 3)

    Parameters

    • delta: number

    Returns Promise<boolean>

    true if this transition caused the job to complete

  • Executes the 3-step Leg2 protocol using GUID ledger for crash-safe resume. Each step bundles durable writes with its concluding digit update in a single transaction.

    Parameters

    • delta: number
    • shouldFinalize: boolean

    Returns Promise<boolean>

    true if this transition caused the job to complete

  • Leg1 entry verification for Category B activities (Leg1-only with children). Returns true if this is a resume (Leg1 already completed on a prior attempt). On resume, loads the GUID ledger for step-level resume decisions.

    Returns Promise<boolean>

  • Upon entering leg 2 of a duplexed activity. Increments both the activity ledger (+1) and GUID ledger (+1). Stores the GUID ledger value for step-level resume decisions.

    Returns Promise<number>