grafana/k6 · error
parsing type options
Error message
parsing type options: %w
What it means
Thrown synchronously when the options argument to locator.type(text, opts) fails to parse. The mapping (locator_mapping.go:388-392) builds common.FrameTypeOptions (seeding ElementHandleTypeOptions with the locator timeout) and wraps Parse failures as "parsing type options: %w". Parse reads delay, noWaitAfter and timeout with coercing accessors that do not fail on plain mistyped values, so an actual occurrence means sobek raised while reading the object — a throwing getter, a Proxy trap, or a value whose coercion to number throws.
Solutions
- Pass a plain literal: locator.type('user@example.com', { delay: 20 })
- Materialize computed values before the call
- Do not wrap options in Proxies or define getters on them
- Catch synchronously with try/catch if options come from untrusted sources
Example fix
// before
await locator.type(creds.user, { get delay() { return getTypingDelay(); } }); // throws when config missing
// after
const delay = getTypingDelay() ?? 0;
await locator.type(creds.user, { delay }); Defensive patterns
Strategy: try-catch
Type guard
function isPlainTypeOptions(o) {
return o == null || (typeof o === 'object' &&
(o.delay === undefined || Number.isFinite(o.delay)) &&
(o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
(o.timeout === undefined || Number.isFinite(o.timeout)));
} Try / catch
try {
await locator.type(text, opts);
} catch (e) {
throw new Error(`type failed (options must be plain delay/noWaitAfter/timeout values): ${e}`);
} Prevention
- Pass delay/timeout as plain numbers
- Precompute dynamic option values
- Keep options object a literal with documented keys only
When it happens
Trigger: Options with a raising getter on delay/noWaitAfter/timeout; Proxy-wrapped options whose traps throw; a timeout/delay with a throwing toPrimitive/valueOf.
Common situations: Typing helpers with lazily-resolved delay config; debugging Proxies over all arguments; Playwright-to-k6 ports where option objects were subclassed with accessors.
Related errors
- parsing fill options
- parsing focus options
- parsing get attribute options
- parsing hover options
- parsing inner HTML options
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/d72b2051a22f2057.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:392
return promise(vu, func() (any, error) {
return nil, lo.Press(key, copts) //nolint:wrapcheck
}), nil
},
"pressSequentially": func(text string, opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing locator press sequentially options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.PressSequentially(text, copts) //nolint:wrapcheck
}), nil
},
"type": func(text string, opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing type options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.Type(text, copts) //nolint:wrapcheck
}), nil
},
"hover": func(opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameHoverOptions(rt, opts, lo.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing hover options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, lo.Hover(copts) //nolint:wrapcheck
}), nil
},
"tap": func(opts sobek.Value) (*sobek.Promise, error) {
copts, err := parseFrameTapOptions(rt, opts, lo.DefaultTimeout())
if err != nil {
return nil, fmt.Errorf("parsing locator tap options: %w", err)View on GitHub (pinned to 8d06114777)