grafana/k6 · error
waitForEvent does not support option
Error message
waitForEvent does not support option: '%s'
What it means
Raw parser error from parsePageWaitForEventOptions: while iterating the page.waitForEvent options object, a key other than 'timeout' or 'predicate' was found. The offending key name is included in the message; the error is typically seen wrapped by 'parsing waitForEvent options'.
Solutions
- Move all filtering logic into the predicate function; keep only { timeout, predicate }.
- Write the predicate to encode the URL filter: e => e.url().includes('/api').
- Delete leftover keys from copy-pasted options objects.
- Set the default timeout once via page.setDefaultTimeout to shrink option objects.
Example fix
// before
await page.waitForEvent('request', { url: '**/api/**' });
// after
await page.waitForEvent('request', { predicate: e => /\/api\//.test(e.url()) }); Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = new Set(['timeout', 'predicate']);
const extra = Object.keys(opts ?? {}).filter(k => !ALLOWED.has(k));
if (extra.length) throw new Error(`waitForEvent does not support: ${extra.join(', ')}`);
await page.waitForEvent('request', opts); Type guard
const isWaitForEventOptions = (o) => o == null || (typeof o === 'object' && Object.keys(o).every(k => k === 'timeout' || k === 'predicate'));
Prevention
- Encode URL/method filters in the predicate function body.
- Keep a project-level constant of allowed keys per wait API and validate before calls.
When it happens
Trigger: page.waitForEvent('request', { url: '**/api', timeout: 5000 }) (url key unsupported); { headers: ... }, { method: ... }, or any Playwright-only filter key placed in the options object.
Common situations: Assuming waitForEvent accepts URL/method filters as options (k6 requires encoding them in the predicate); sharing an options literal between waitForResponse and waitForEvent; stale keys after refactors.
Related errors
- parsing waitForEvent options
- parsing frame wait for navigation options
- parsing waitForFunction options
- parsing waitForRequest options
- parsing waitForResponse options
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/e118933a674679b7.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:1180
if fn, ok := sobek.AssertFunction(opts); ok {
return ropts, fn, nil
}
obj := opts.ToObject(k6ext.Runtime(ctx))
var pred sobek.Callable
for _, k := range obj.Keys() {
switch k {
case "timeout":
ropts.Timeout = time.Duration(obj.Get(k).ToInteger()) * time.Millisecond
case "predicate":
fn, ok := sobek.AssertFunction(obj.Get(k))
if !ok {
return nil, nil, fmt.Errorf("predicate must be a function")
}
pred = fn
default:
return nil, nil, fmt.Errorf("waitForEvent does not support option: '%s'", k)
}
}
return ropts, pred, nil
}
// parseSize parses the size options from a Sobek value.
func parseSize(rt *sobek.Runtime, opts sobek.Value) (*common.Size, error) {
size := &common.Size{}
if k6common.IsNullish(opts) {
return size, nil
}
obj := opts.ToObject(rt)
for _, k := range obj.Keys() {
v := obj.Get(k)
if k6common.IsNullish(v) {
continueView on GitHub (pinned to 8d06114777)