grafana/k6 · critical · Error
"${attr}" attribute is only supported for roles: ${roles.sli
Error message
"${attr}" attribute is only supported for roles: ${roles.slice().sort().map((role2) => `"${role2}"`).join(", ")} What it means
An internal-invariant Go panic in ModuleSystem.getModuleInstanceFromGoModule (js/modules/require_impl.go:91-95). After linking and evaluating a goModule (a module implemented in Go, like k6/http), the code fetches the module instance the runtime associated with it and asserts it is a *goModuleInstance; any other concrete type means the runtime's module-instance bookkeeping disagrees with k6's wrapper. Like the message says, this is a k6 bug to report, not a script error, and as a raw panic it aborts the process rather than surfacing as a JS exception.
Source
Thrown at internal/js/modules/k6/browser/common/js/injected_script.js:1150
result.name = readIdentifier();
skipSpaces();
while (next() === "[") {
result.attributes.push(readAttribute());
skipSpaces();
}
if (!EOL)
syntaxError(void 0);
if (!result.name && !result.attributes.length)
throw new InvalidSelectorError(`Error while parsing selector \`${selector}\` - selector cannot be empty`);
return result;
}
// packages/injected/src/roleSelectorEngine.ts
var kSupportedAttributes = ["selected", "checked", "pressed", "expanded", "level", "disabled", "name", "include-hidden"];
kSupportedAttributes.sort();
function validateSupportedRole(attr, roles, role) {
if (!roles.includes(role))
throw new Error(`"${attr}" attribute is only supported for roles: ${roles.slice().sort().map((role2) => `"${role2}"`).join(", ")}`);
}
function validateSupportedValues(attr, values) {
if (attr.op !== "<truthy>" && !values.includes(attr.value))
throw new Error(`"${attr.name}" must be one of ${values.map((v) => JSON.stringify(v)).join(", ")}`);
}
function validateSupportedOp(attr, ops) {
if (!ops.includes(attr.op))
throw new Error(`"${attr.name}" does not support "${attr.op}" matcher`);
}
function validateAttributes(attrs, role) {
const options = { role };
for (const attr of attrs) {
switch (attr.name) {
case "checked": {
validateSupportedRole(attr.name, kAriaCheckedRoles, role);
validateSupportedValues(attr, [true, false, "mixed"]);
validateSupportedOp(attr, ["<truthy>", "="]);
options.checked = attr.op === "<truthy>" ? true : attr.value;View on GitHub (pinned to 93accf6570)
Solutions
- Switch the affected module to a native ES import: `import http from 'k6/http';` — this uses the ESM evaluation path and avoids Require's go-module branch
- Report the issue at https://github.com/grafana/k6/issues with the script and `k6 version` output
- Reproduce with a minimal script (`const http = require('k6/http'); export default function(){}`) to attach to the report
- Try another k6 release if you need to keep the require() style; check release notes for module-system fixes
Example fix
// before
const http = require('k6/http'); // panics in getModuleInstanceFromGoModule
// after
import http from 'k6/http'; // ESM import path, no Require() go-module branch Defensive patterns
Strategy: fallback
Validate before calling
null
Try / catch
// Raw Go panic from the module system — not catchable from JS.
// Avoid the failing path entirely: use ESM imports instead of require() for Go-backed modules.
// import http from 'k6/http'; // instead of: const http = require('k6/http');
// import { check } from 'k6'; // instead of: const { check } = require('k6'); Prevention
- Use `import x from 'k6/<module>'` for all built-in and Go-implemented modules; reserve require() for local file modules when possible
- Smoke-test `const m = require('k6/http')` once per k6 upgrade; if it panics, switch that call site to import
- Pin k6 in CI and review release notes for js/modules changes before upgrading
- Report the panic (it is an acknowledged k6 bug) with script and version
When it happens
Trigger: Calling require() on a Go-implemented module, e.g. `const http = require('k6/http')` — Require (require_impl.go:35-37) routes goModules through getModuleInstanceFromGoModule. The panic fires when rt.GetModuleInstance(wm) returns a non-goModuleInstance value, typically after a sobek/k6 version change in how instances are cached or instantiated.
Common situations: Scripts written in CommonJS style that require() built-in k6 modules instead of importing them; upgrading k6 or its sobek dependency and hitting a module-instance regression; running a custom xk6 binary whose extensions interact with the module system in unsupported ways.
Related errors
- Error while parsing selector `${selector}` - selector cannot
- CommonJS's exports must not be null
- the "require" function is only available in the init stage (
- Error while parsing selector `${selector}` - cannot use ${op
- require() can't be used with an empty specifier
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/1fbe7d1e250ade92.
Report an issue: GitHub.