Skip to content

Commit

Permalink
Add warning to the group API about asynchronize code (#1011)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Dodson <47385188+MattDodsonEnglish@users.noreply.github.com>
Co-authored-by: na-- <n@andreev.sh>
  • Loading branch information
3 people authored Jan 31, 2023
1 parent ae64d0f commit 1471633
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ Run code inside a group. Groups are used to organize results in a test.
| ---- | ------------------------- |
| any | The return value of _fn_. |

<Blockquote mod="warning" title="Working with async functions">

Avoid using `group` with async functions or asynchronous code.
If you do, k6 might apply tags in a way that is unreliable or unintuitive.

If you start promise chains or even use `await` within `group`, some code within the group will be waited for and tagged with the proper `group` tag, but others won't be.

To avoid confusion, `async` functions are forbidden as `group()` arguments. This still lets users make and chain promises within a group, but doing so is unsupported and not recommended.

For more information, refer to [k6 #2728](https://github.com/grafana/k6/issues/2728), which tracks possible solutions and provides detailed explanations.

</Blockquote>

### Example

<CodeGroup labels={[]}>
Expand Down

0 comments on commit 1471633

Please sign in to comment.