k6/Browser Shared Worker support?
Brief summary
I have a large NodeJS MFE webpage that relies on a shared worker to validate auth before allowing the user into the landing page. When attempting to setup k6/browser perf tests for our application, I have been able to successfully navigate to the webpage, automatically get redirected to the auth flow, k6 is able to automate the auth inputs to complete the auth flow, get redirected back to the desired webpage, but then gets hung up waiting for the shared worker to validate the authentication.
I am able to confirm the hangup is due to the shared worker because if I am actively inspecting the worker through chrome://inspect/#workers and open the sso-worker's DevTools inspect page, when I reload the webpage, everything works as expected.
Overall, I am wondering if shared workers have no support or compatibility with k6/browser currently, the docs have no reference to them so I cannot confirm one way or the other. We are able to fully e2e test our application through Playwright with no loading issues related to our shared worker. We are very unsure what could be causing this hangup because everything LOOKS like it is a regular Chrome session.
k6 version
k6 v1.0.0-rc1 (go1.24.1, darwin/arm64)
OS
macOS 15.3.2
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Here is the MVP repo to replicate the issue, steps to reproduce are listed in the README.
Expected behaviour
- Navigate to webpage, redirect to auth, complete auth workflow, redirect back to webpage, fully load landing page with no hangup.
Actual behaviour
- Navigate to webpage, redirect to auth, complete auth workflow, redirect back to webpage, hang on loading screen because shared worker does not seem to be fully initialized/operable in unless I manually inspect it.
Here is a repo that walks through reproducing the issue: https://github.com/camanderson/k6-browser-shared-worker-issue
Hi @camanderson,
Apologies because this got completely out of my radar 🙇🏻 Indeed, I really appreciate that you first worked on a example that reproduces the issue, and how well you described it. In any case, I'm back, and willing to help you!
However, being completely honest, I'm not familiar at all with the web/browser ecosystem (shared works, CDP, the involved events, etc, etc), and my experience with k6 Browser's codebase is little. So, my range of action here is a bit limited. Perhaps @inancgumus can help.
So far, I've written some lines (see https://github.com/grafana/k6/pull/5372) that seem to make some progress over the example you shared. Of course, even in the best scenario, these will require some polishing, some reviewal and definitely adding some coverage, to prevent regressions.
But in the meantime, would you be able to download the binaries from https://github.com/grafana/k6/actions/runs/19137224280, and try to see if that works for you? If these lines would solve the issues you faced when testing your NodeJS MFE webpage, or at least make some little progress, would be really nice.
Looking forward to your feedback! Thanks!
I am wondering if shared workers have no support or compatibility with k6/browser currently
Hi @camanderson, unfortunately, k6-browser doesn't support workers yet :( @joanlopez Nice work 👍 Like you said, this feature needs some more work, but the PR is on the right track!
We are hitting a similar issue with our implementation of K6, is it possible to get those binaries regenerated. I'd like to see if this resolves our issue as well.