Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 165d7ce

Browse files
authoredNov 4, 2024··
docs: flow.exit updates
1 parent 50c1714 commit 165d7ce

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎docs-v2/pages/code/nodejs/index.mdx

+15-3
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,28 @@ Sometimes you want to end your workflow early, or otherwise stop or cancel the e
387387
**In any code step, calling `return $.flow.exit()` will end the execution of the workflow immediately.** No remaining code in that step, and no code or destination steps below, will run for the current event.
388388

389389
<Callout type="info">
390-
It's a good practice to use `return $.flow.exit()` to immediately exit the workflow.
391-
In contrast, `$.flow.exit()` on its own will end the workflow only after executing all remaining code in the step.
390+
`$.flow.exit()` does not exit the workflow immediately, only after all remaining code has been executed.
391+
If you want to exit the workflow immediately, you need to use other control structures to do so.
392+
It is best practice to return the value of `$.flow.exit()`.
392393
</Callout>
393394

395+
```javascript
396+
export default defineComponent({
397+
async run({ steps, $ }) {
398+
$.flow.exit();
399+
console.log(
400+
"This code will still run, the workflow is ended after"
401+
);
402+
},
403+
});
404+
```
405+
394406
```javascript
395407
export default defineComponent({
396408
async run({ steps, $ }) {
397409
return $.flow.exit();
398410
console.log(
399-
"This code will not run, since $.flow.exit() was called above it"
411+
"This code will not run, as we returned from the `run` function early"
400412
);
401413
},
402414
});

0 commit comments

Comments
 (0)
Please sign in to comment.