You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the browser module relies on the the events that it is subscribed to control its lifecycle. The reasons we have this is to allow the browser module to control the number of chromium instances that are used per test run.
An unexpected consequence of working with the event system is that we were unable to easily work with the vu context to allow k6 to abort tests early. If a vu context was used to control the chromium subprocess/connection then there would be a race condition between chromium unexpectedly shutting down when the iteration ends and the current API calls being made via CDP.
When this doesn't work is when a gracefulStop occurs (SIGTERM for example) and the iteration's vu context is closed. At this point k6 expects the current API call to cancel itself since the context is closed and allow it to clean itself up and gracefully shutdown.
Since the browser module isn't working with the vu context, it fails to shut it self down promptly, which can result in various other timeouts elsewhere. We should look at using the vu context to control the API calls, but rely on the events to control the chromium browser lifecycle -- IterEnd and exit events are called once the iteration's vu context is closed and the browser module hands over the main thread back to k6.
xk6-browser version
v0.53.0
OS
NA
Chrome version
NA
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Run the following script, which will block the iteration and then send a SIGTERM signal (kill -15 {pid}) to the k6 process—it won't quit the process (until a default of 30 seconds or a user-specified timeout elapses):
This is a temporary solution to a problem the browser module is facing
when a signal (e.g. SIGTERM) is handled by k6, but is not correctly
handled by the browser module. The reason is due to it not working with
the vu context. More details in the open issue:
grafana/xk6-browser#1410.
The introduction of a temporary abort event will be fired, which the
browser module can intercept and action on immediately.
Brief summary
Currently the browser module relies on the the events that it is subscribed to control its lifecycle. The reasons we have this is to allow the browser module to control the number of chromium instances that are used per test run.
An unexpected consequence of working with the event system is that we were unable to easily work with the vu context to allow k6 to abort tests early. If a vu context was used to control the chromium subprocess/connection then there would be a race condition between chromium unexpectedly shutting down when the iteration ends and the current API calls being made via CDP.
The work around for this is to use a background context that is created when the module is created. This means the module relies on the events system to correctly shut down iterations.
When this doesn't work is when a gracefulStop occurs (SIGTERM for example) and the iteration's vu context is closed. At this point k6 expects the current API call to cancel itself since the context is closed and allow it to clean itself up and gracefully shutdown.
Since the browser module isn't working with the vu context, it fails to shut it self down promptly, which can result in various other timeouts elsewhere. We should look at using the vu context to control the API calls, but rely on the events to control the chromium browser lifecycle --
IterEnd
andexit
events are called once the iteration's vu context is closed and the browser module hands over the main thread back to k6.xk6-browser version
v0.53.0
OS
NA
Chrome version
NA
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Run the following script, which will block the iteration and then send a
SIGTERM
signal (kill -15 {pid}
) to the k6 process—it won't quit the process (until a default of 30 seconds or a user-specified timeout elapses):Expected behaviour
The test exits promptly and doesn't wait for the timeout to occur.
Actual behaviour
The browser module waits for the timeout to occur.
Tasks
The text was updated successfully, but these errors were encountered: