k6
k6 copied to clipboard
Warn users on unsupported parts of `setup` returned data
Feature Description
Currently setup
can return whatever and it will be send to default
and teardown
.
A lot of users are confused what actually happens because for the most part it works perfectly and as long as you:
- don't put unsupported types in the data
- don't expect that edititng it will be observable between VUs and stages
you can 100% think that it is just that exact same object.
But it isn't - it is a copy made by marshalling and then unmarshalling from JSON. This definitely makes it so
- If you have added a function it will be
nil
... which is very confusing. Doubly so if it's a method on a class and the instance of that class is still there. - You try to edit it and expect that
teardown
will see the changes.
Both of those are kind of documented, but I would expect that a lot of people wouldn't find them.
Suggested Solution (optional)
Write some, hopefully not very complicated code, to go through the whole object and check for known problems such as functions
and print a warning
about it.
We can probably try to write the name of the property or even the "path" to it as that will improve the message a lot.
For the second one we have discussed it a lot in https://github.com/grafana/k6/issues/2043, but I wonder if we can just freeze
that object after it's unmarshalled :shrug:
Already existing or connected issues / PRs (optional)
https://github.com/grafana/k6/issues/2043