-
Notifications
You must be signed in to change notification settings - Fork 41
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
Non-iterational goroutines should not abort an iteration #688
Comments
Types of panic
Panic vs ErrorErrorShould denote to the user that an error occurred but there's a way around it, i.e. they can fix it themselves. This shouldn't stop the whole test but just the current iteration. PanicShould denote an abort of the whole test run (all iterations) as an unexpected internal error was encountered which we need to fix e.g. the goja runtime is missing from the content. The assumption i'm making is that if it happens in the current iteration it's probably happening in all iterations. Areas where I think are ok to use panic (abort the whole test run)NOTE:
List of panics that could be errors (only stop the current test iteration)
Question
|
We briefly discussed the strategy going forward, and we've agreed that we should pick a file and convert the Based on the feedback from the first PR, we should be able to convert the rest of the codebase. |
@ankur22, what I have in mind is to let the mapping layer handle the panics and the internal (core/business logic) parts of the code return errors. This is more idiomatic and maintainable in the long run (from the perspective of tests + code). But it's not something you necessarily need to tackle in this issue. I agree with the rest of your findings 👍 |
That's a good idea. We could assert on the behaviour of the error to determine whether to panic or return the error: https://dave.cheney.net/2014/12/24/inspecting-errors |
* Add error handling to wildcard selectors This allows us to: - Better handle extension errors. - Leaves the decision of properly handling errors to Goja when an element is not found. This is how it's done in the k6-core and other extensions. - Returning an error from the mapping layer also prevents multiple unnecessary panics. Updates: #804 Related: #688
Brief summary
Goroutines other than the one that drives an iteration should not panic. Otherwise, k6 won't catch the panic and fail.
We should take control of our non-iteration goroutines: Not panic and cause an iteration to be prematurely aborted.
More details about how to craft a solution:
xk6-browser version
v0.7.0
OS
Staging Cloud
Docker version and image (if applicable)
grafana/k6-cloud-scripts-to-archive:2.40.6-xk6browser-v0.7.0-1
Steps to reproduce the problem
Pawel ran the following script, and we got sentry alerts because of the panics.
This script panics.
The script has an incorrect usage of promises, and the fix is easy:
However, the problem is deeper than it seems.
See more details in the test run: 1620122 (proxy).
Actual behaviour
Panic causes an iteration to be prematurely aborted.
Tasks
The text was updated successfully, but these errors were encountered: