Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update recommendation for async check #4037

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Nov 5, 2024

What?

This change updates the recommendation for using the check polyfill that does support async functions.

https://grafana.com/docs/k6/latest/javascript-api/jslib/utils/check/

Why?

It improves UX of k6.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

@olegbespalov olegbespalov requested a review from a team as a code owner November 5, 2024 08:08
@olegbespalov olegbespalov requested review from mstoykov and oleiade and removed request for a team November 5, 2024 08:08
@olegbespalov olegbespalov added the ux label Nov 5, 2024
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

@@ -182,7 +179,9 @@ func (mi *K6) Check(arg0, checks sobek.Value, extras ...sobek.Value) (bool, erro
}

if common.IsAsyncFunction(rt, val) {
return false, fmt.Errorf(asyncFunctionNotSupportedMsg, "check")
return false, errors.New("built-in check() does not support async functions as arguments, " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably good idea either here or/and the linked utils to explain why this is a problem similar to how it does it fro group.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heitortsergent maybe we should fix this part in the docs ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense @mstoykov. I'll open an issue for it. 🙇

@olegbespalov olegbespalov added this to the v0.55.0 milestone Nov 5, 2024
@olegbespalov olegbespalov merged commit 1d6d66e into master Nov 5, 2024
23 checks passed
@olegbespalov olegbespalov deleted the chore/check-async-warn branch November 5, 2024 10:42
Copy link
Contributor

@heitortsergent heitortsergent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this already got merged, but just left two small suggestions for updating the messages. 🤓

@@ -104,7 +100,8 @@ func (mi *K6) Group(name string, val sobek.Value) (sobek.Value, error) {
return nil, errors.New("group() requires a callback as a second argument")
}
if common.IsAsyncFunction(mi.vu.Runtime(), val) {
return sobek.Undefined(), fmt.Errorf(asyncFunctionNotSupportedMsg, "group")
return sobek.Undefined(), errors.New("group() does not support async functions as arguments, " +
"please see https://grafana.com/docs/k6/latest/javascript-api/k6/group/#working-with-async-functions for more info")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a small nit, we don't have the heading #working-with-async-functions on that page, so you could just link to: https://grafana.com/docs/k6/latest/javascript-api/k6/group/.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! @heitortsergent

@@ -182,7 +179,9 @@ func (mi *K6) Check(arg0, checks sobek.Value, extras ...sobek.Value) (bool, erro
}

if common.IsAsyncFunction(rt, val) {
return false, fmt.Errorf(asyncFunctionNotSupportedMsg, "check")
return false, errors.New("built-in check() does not support async functions as arguments, " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The built-in check() does not support async functions as arguments. Use the JavaScript utils library as a replacement. Refer to https://grafana.com/docs/k6/latest/javascript-api/jslib/utils/check/ for more info"

Small suggestion for the message on these lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've opened the #4043 for addressing 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants