-
Notifications
You must be signed in to change notification settings - Fork 1.4k
js: Error with a list of unknown k6/*
modules
#5240
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
Conversation
js/modules/resolution.go
Outdated
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | ||
"this likely means binary provisioning is required or a custom k6 binary with more extensions", | ||
u.unknownModules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the wording should be along the lines of:
couldn't load unknown modules %q -- likely due to either requiring binary provisioning or needing a custom k6 binary with the required extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | |
"this likely means binary provisioning is required or a custom k6 binary with more extensions", | |
u.unknownModules) | |
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | |
"this likely means automatic extension extension is required or a custom k6 binary with more extensions", | |
u.unknownModules) |
in addition to @ankur22's suggestion, binary provisioning is an outdated name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codebien FYI: automatic extension extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the message
debf652
to
43b615c
Compare
dd68b1a
to
1ae83b8
Compare
The base branch was changed.
1ae83b8
to
4d232bb
Compare
This doesn't abort immediately the execution, but continues the resolution step and then errors if there are any unknown modules. This allows the resolution to continue finding unknown modules and potentially even let us then get a new binary that can run the script.
4d232bb
to
2142f1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main logic LGTM, added a few minor comments
js/modules/resolution.go
Outdated
panic("somehow running source data for " + specifier + " didn't produce a cyclic module record") | ||
} | ||
|
||
unknownModules := mr.unknownModules() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unknownModules := mr.unknownModules() | |
if mr.unknownModules() > 0 { | |
return newUnknownModulesError(mr.unknownModules()) | |
} |
We can probably avoid to allocate it for the happy path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with two different thigns and in the end remembered that where we add to the map, we already go through cachining so it will be called once. So I opted for just adding to a slice in the end.
js/modules/resolution.go
Outdated
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | ||
"this likely means binary provisioning is required or a custom k6 binary with more extensions", | ||
u.unknownModules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | |
"this likely means binary provisioning is required or a custom k6 binary with more extensions", | |
u.unknownModules) | |
return fmt.Sprintf("unknown modules %q were tried to be loaded, but couldn't - "+ | |
"this likely means automatic extension extension is required or a custom k6 binary with more extensions", | |
u.unknownModules) |
in addition to @ankur22's suggestion, binary provisioning is an outdated name
} | ||
|
||
func (u UnknownModulesError) Error() string { | ||
return fmt.Sprintf("unknown modules [%s] were tried to be loaded, but couldn't - "+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is still a bit of improvement to be done to have a better DX. A revisited version of original Ankur's proposal.
return fmt.Sprintf("unknown modules [%s] were tried to be loaded, but couldn't - "+ | |
return fmt.Sprintf("unknown module(s): [%s] k6 couldn't resolve the them because they are not built-in k6 modules. If these are extension modules, enable automatic extension resolution or build a custom binary with xk6. See the docs for more details: https://grafana.com/docs/k6/latest/extensions/explore/#use-extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we are going overboard on this.
There are more changes to come, and this error is either never going to be seen. Or it will be seen before it either loads a new binary or returns a next error about extension resolutions.
I would prefer all the DX/UX work to be done after we move to the new implementation, which already fix bugs that are reported and people have problems with. I do not think that if someone has disabled auto extension resolution, they would not know about extensions.
} | ||
} | ||
|
||
// UnknownModulesError is returned when loading a module was not possbile due to one or more of dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// UnknownModulesError is returned when loading a module was not possbile due to one or more of dependencies | |
// UnknownModulesError is returned when loading a module was not possible due to one or more of dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit; ofc non-blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand the role of the unknownModule
and whether panic
icking only on Evaluate
is enough to catch any possible misuse, but overall looks good 👍🏻
@joanlopez if the loading could find a module, the Sobek (ESM) resolution mechanism will stop ... because well, it could find it. But what we want here is for it to continue until we have loaded everything that we can. And then we will check "did we try to load anything that was not found" if so ... abort and propagate back what that was. This allows us to have k6 internally figure out that The panic is because an unknown module should never actually be evaluated, if it is that is a bug somewhere else. We only parse the code and link the modules together. |
@mstoykov Thanks for the detailed explanation! 🙌🏻 🙇🏻 I think I got most of it (especially the high-level picture, and the main purpose), what I wasn't completely sure was if there could be a misuse (now or introduced in the future by mistake) somehow hidden because only |
What?
This doesn't abort immediately the execution, but continues the resolution step and then errors if there are any unknown modules.
Why?
This allows the resolution to continue finding unknown modules and potentially even let us then get a new binary that can run the script.
Checklist
make check
) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
Related PR(s)/Issue(s)