Skip to content

Commit 12fddc1

Browse files
authored
Update plugin docs with async condition guidance (#782)
Note how to use async plugins in gitStream condition clauses with immediate: true flag and the implications for optimization and API calls
1 parent 79f39cc commit 12fddc1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/plugins-for-developers.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@ automations:
6464
!!! warning "15 Minute Time Limit"
6565
gitStream actions are terminated after 15 minutes, this is a hard limit that can't be extended.
6666

67+
#### Using Async Plugin in Conditions
68+
69+
Normally, gitStream optimizes plugin execution by rendering plugins only after condition evaluation when all automation rules are decided. This optimization prevents unnecessary plugin calls.
70+
71+
However, when using an async plugin in a **condition** without the `immediate: true` flag, this optimization causes the plugin to not work properly, and you will see warning messages in the logs.
72+
73+
To use an async plugin in a condition, you must annotate the plugin with `immediate: true`:
74+
75+
```javascript
76+
module.exports = {
77+
async: true,
78+
immediate: true,
79+
filter: myFilter
80+
}
81+
```
82+
83+
The `immediate: true` flag tells the system not to optimize plugin execution. The downside is that the plugin might be called multiple times during the workflow execution. If your plugin makes API calls, this will result in multiple API requests as well.
84+
85+
```yaml+jinja
86+
automations:
87+
welcome_author:
88+
if:
89+
- {{ "" | myFilter }}
90+
run:
91+
- action: add-comment@v1
92+
args:
93+
comment: hello world!
94+
```
95+
6796
### Accept Arguments
6897

6998
Filter function plugins can accept any number of arguments. The first argument must be passed to the filter function via a ` | ` operator; all subsequent arguments are passed as a set inside parenthesis.

0 commit comments

Comments
 (0)