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

Warn on access to the exported script options instead of test.options in k6/execution #2601

Open
na-- opened this issue Jul 14, 2022 · 1 comment
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 js-compat ux

Comments

@na--
Copy link
Member

na-- commented Jul 14, 2022

From https://github.com/grafana/k6/pull/2571/files#r921222735

There are various issues when scripts try to access the exported script options from the script. #2571 fixes one bug/undefined behavior, but there are a few other subtle problems.

I think it would be relatively easy to make this into a DynamicObject that prints a warning if anyone tries to access any of the properties? 🤔

We can warn people (with a sync.Once, to limit spam) to use test.options from k6/execution for read (i.e. Get(), Keys() and Has()) operations. And also warn (with another sync.Once) them that modifying the options (i.e. on Set() and Delete()) during the script runtime is useless and won't actually affect anything during the script execution.

@na--
Copy link
Member Author

na-- commented Jul 18, 2022

This will probably be tricky to implement, since we will have to do it on a key by key basis, not on the whole options object, see the discussion in #2571 (comment) 😞

@na-- na-- added the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluation needed proposal needs to be validated or tested before fully implementing it in k6 js-compat ux
Projects
None yet
Development

No branches or pull requests

1 participant