grafana/k6 · error
parsing type options: %w
Error message
parsing type options: %w
What it means
Thrown synchronously by ElementHandle.type() when its options fail to parse. ElementHandleTypeOptions (delay, noWaitAfter, timeout) is parsed with lenient coercions only in common/element_handle_options.go and always returns nil, so this wrap is defensive and effectively unreachable in current k6. The text argument is typed and cannot cause this error.
Source
Thrown at internal/js/modules/k6/browser/browser/element_handle_mapping.go:267
return nil, eh.Tap(popts) //nolint:wrapcheck
}), nil
},
"textContent": func() *sobek.Promise {
return promise(vu, func() (any, error) {
s, ok, err := eh.TextContent()
if err != nil {
return nil, err //nolint:wrapcheck
}
if !ok {
return nil, nil
}
return s, nil
})
},
"type": func(text string, opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleTypeOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing type options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.Type(text, popts) //nolint:wrapcheck
}), nil
},
"uncheck": func(opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing uncheck options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, eh.Uncheck(popts) //nolint:wrapcheck
}), nil
},
"waitForElementState": func(state string, opts sobek.Value) (*sobek.Promise, error) {
popts := common.NewElementHandleWaitForElementStateOptions(eh.DefaultTimeout())
if err := popts.Parse(vu.Context(), opts); err != nil {
return nil, fmt.Errorf("parsing waitForElementState options: %w", err)View on GitHub (pinned to 93accf6570)
Solutions
- Use { delay: <ms number>, noWaitAfter: <bool>, timeout: <ms number> }
- Prefer el.fill() for setting whole values; use type() only to exercise per-key events
- Upgrade k6 if this message appears and retest with an empty options object
- Read the wrapped cause after the colon for the failing field
Example fix
// before
await el.type('hello', { delay: '100', timeout: '5s' });
// after
await el.type('hello', { delay: 100, timeout: 5000 }); Defensive patterns
Strategy: try-catch
Validate before calling
if (opts) {
if (opts.delay !== undefined && !Number.isFinite(Number(opts.delay))) throw new Error('type(): delay must be ms number');
if (opts.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) throw new Error('type(): timeout must be ms number');
}
const ALLOWED = new Set(['delay', 'noWaitAfter', 'timeout']);
const bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));
if (bad.length) console.warn(`type(): unsupported options ignored: ${bad.join(', ')}`); Type guard
function isTypeOpts(o) {
if (o == null) return true;
return (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 el.type(text, opts);
} catch (e) {
if (/parsing type options/.test(String(e.message))) {
console.log(`fix type options: ${e.message}`);
} else throw e;
} Prevention
- delay and timeout are millisecond numbers; strings coerce silently to wrong values
- Prefer fill() for whole-value input; keep type() for per-keypress event simulation
- Current k6 cannot raise this parse error; occurrence signals an old binary or regression
When it happens
Trigger: In current code none: delay/noWaitAfter/timeout coerce any value; unknown keys are ignored. Old xk6-browser builds with structural parsing could fail on mismatched field types.
Common situations: Passing delay/timeout as strings ('100'), which coerce to numbers rather than erroring; Playwright ports carrying unsupported keys that are silently ignored.
Related errors
- parsing check options: %w
- parsing element click options: %w
- parsing element double click options: %w
- parsing element fill options: %w
- parsing element hover options: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/4881e9bef05382a1.
Report an issue: GitHub.