grafana/k6 · error
unsupported waitForRequest option
Error message
unsupported waitForRequest option: '%s'
What it means
Raw parser error surfaced (wrapped) by page.waitForRequest(url, opts): the options object iteration found a key other than the single accepted 'timeout' key. This is the concrete cause inside the 'parsing waitForRequest options' wrapper and names the rejected key.
Solutions
- Keep the options object to { timeout: <ms> } only.
- Filter by URL with a RegExp first argument: page.waitForRequest(/\/api\/submit/).
- For method/body conditions, use page.waitForEvent('request', { predicate }) instead.
- Lint scripts for known-invalid keys before running (e.g. a grep in CI for 'method' inside waitForRequest options).
Example fix
// before
await page.waitForRequest('**/submit', { method: 'POST' });
// after
await page.waitForEvent('request', { predicate: r => r.method() === 'POST' && r.url().includes('/submit') }); Defensive patterns
Strategy: validation
Validate before calling
function assertWaitForRequestKeys(opts) {
const extra = Object.keys(opts ?? {}).filter(k => k !== 'timeout');
if (extra.length) throw new Error(`unsupported waitForRequest option(s): ${extra.join(', ')}`);
}
assertWaitForRequestKeys({ timeout: 5000 });
await page.waitForRequest(/\/submit/, { timeout: 5000 }); Type guard
const hasOnlyTimeoutKey = (o) => o == null || Object.keys(o).every(k => k === 'timeout');
Prevention
- Filter requests with a RegExp pattern or a waitForEvent predicate, not option keys.
- Review migrated Playwright lines that pass method/headers to waitForRequest.
When it happens
Trigger: page.waitForRequest(url, { timeout: 5000, url: '**/filter' }), { method: 'POST' }, { predicate: fn }, or any extra property on the second argument.
Common situations: Trying to filter requests by method/headers through options (unsupported — use a RegExp or waitForEvent with a predicate instead); reusing an options literal across several wait APIs; autocomplete inserting Playwright-only keys.
Related errors
- parsing waitForRequest options
- parsing frame wait for navigation options
- parsing waitForEvent options
- parsing waitForFunction options
- parsing waitForResponse options
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/cbd6cf25ec9a900d.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:1144
func parsePageWaitForRequestOptions(
ctx context.Context, opts sobek.Value, defaultTimeout time.Duration,
) (*common.PageWaitForRequestOptions, error) {
ropts := common.PageWaitForRequestOptions{
Timeout: defaultTimeout,
}
if k6common.IsNullish(opts) {
return &ropts, nil
}
obj := opts.ToObject(k6ext.Runtime(ctx))
for _, k := range obj.Keys() {
switch k {
case "timeout":
ropts.Timeout = time.Duration(obj.Get(k).ToInteger()) * time.Millisecond
default:
return &ropts, fmt.Errorf("unsupported waitForRequest option: '%s'", k)
}
}
return &ropts, nil
}
func parsePageWaitForEventOptions(
ctx context.Context, opts sobek.Value, defaultTimeout time.Duration,
) (*common.PageWaitForEventOptions, sobek.Callable, error) {
ropts := &common.PageWaitForEventOptions{
Timeout: defaultTimeout,
}
if k6common.IsNullish(opts) {
return ropts, nil, nil
}
if fn, ok := sobek.AssertFunction(opts); ok {View on GitHub (pinned to 8d06114777)