ctx.exitAll()
Terminates the current event flow and all subsequent event flows triggered in the same event dispatch. It is commonly used when all event flows under the current event need to be aborted immediately due to a global error or permission validation failure.
Use Cases
ctx.exitAll() is generally used in JS-executable contexts where it is necessary to simultaneously abort the current event flow and subsequent event flows triggered by that event:
Difference from
ctx.exit():ctx.exit()only terminates the current event flow;ctx.exitAll()terminates the current event flow and any unexecuted subsequent event flows in the same event dispatch.
Type Definition
Calling ctx.exitAll() throws an internal FlowExitAllException, which is caught by the FlowEngine to stop the current event flow instance and subsequent event flows under the same event. Once called, the remaining statements in the current JS code will not be executed.
Comparison with ctx.exit()
Execution Mode
- Sequential Execution: Event flows under the same event are executed in order. After any event flow calls
ctx.exitAll(), subsequent event flows will not execute. - Parallel Execution: Event flows under the same event are executed in parallel. Calling
ctx.exitAll()in one event flow will not interrupt other concurrent event flows (as they are independent).
Examples
Terminate all event flows when permission validation fails
Terminate when global pre-validation fails
Choosing between ctx.exit() and ctx.exitAll()
Prompt before terminating
Notes
- After calling
ctx.exitAll(), subsequent code in the current JS will not execute. It is recommended to explain the reason to the user viactx.message,ctx.notification, or a modal before calling it. - Business code usually does not need to catch
FlowExitAllException; let the FlowEngine handle it. - If you only need to stop the current event flow without affecting subsequent ones, use
ctx.exit(). - In parallel mode,
ctx.exitAll()only terminates the current event flow and does not interrupt other concurrent event flows.
Related
- ctx.exit(): Terminates only the current event flow
- ctx.message: Message prompts
- ctx.modal: Confirmation modal

