grafana/k6 · error

parsing is enabled options

Error message

parsing is enabled options: %w

What it means

Thrown synchronously when the options argument to locator.isEnabled() fails to parse. The mapping (locator_mapping.go:155-159) creates common.FrameIsEnabledOptions (FrameBaseOptions seeded with the locator timeout) and wraps failures as "parsing is enabled options: %w". Because FrameBaseOptions.Parse reads only strict/timeout via coercing accessors and cannot fail on values, the wrapped error originates in sobek property access on the options object — throwing getters, Proxy traps, or throwing implicit conversions.

Solutions

  1. Pass a plain literal or omit options: locator.isEnabled({ timeout: 2000 })
  2. Precompute any dynamic option values into plain properties
  3. Avoid Proxy or accessor properties on objects handed to the browser module
  4. Use try/catch to convert the synchronous throw into a test failure with context

Example fix

// before
await locator.isEnabled(proxiedOpts); // Proxy get trap throws

// after
await locator.isEnabled({ timeout: proxiedOpts.timeout }); // reads trap safely before call
Defensive patterns

Strategy: try-catch

Type guard

function isPlainBaseOptions(o) {
  return o == null || (typeof o === 'object' &&
    (o.timeout === undefined || typeof o.timeout === 'number') &&
    (o.strict === undefined || typeof o.strict === 'boolean'));
}

Try / catch

try {
  const enabled = await locator.isEnabled(opts);
} catch (e) {
  throw new Error(`isEnabled failed (inspect options object for throwing getters): ${e}`);
}

Prevention

When it happens

Trigger: Options object with a getter for timeout/strict that throws; Proxy-wrapped options with raising get/ownKeys traps; a timeout whose Symbol.toPrimitive raises during ToInteger.

Common situations: Debug/tracing wrappers that proxy every argument; page objects with computed accessors; passing frozen/exotic objects that intercept enumeration.

Related errors


AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14). Data as JSON: /api/errors/7d6221f9537aa9e7. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:158

				return nil, fmt.Errorf("parsing is checked options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.IsChecked(copts) //nolint:wrapcheck
			}), nil
		},
		"isEditable": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameIsEditableOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing is editable options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.IsEditable(copts) //nolint:wrapcheck
			}), nil
		},
		"isEnabled": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameIsEnabledOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing is enabled options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.IsEnabled(copts) //nolint:wrapcheck
			}), nil
		},
		"isDisabled": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameIsDisabledOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing is disabled options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.IsDisabled(copts) //nolint:wrapcheck
			}), nil
		},
		"isInViewport": func(opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameIsInViewportOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing is in viewport options: %w", err)

View on GitHub (pinned to 8d06114777)