grafana/k6 · error

unsupported waitForResponse option

Error message

unsupported waitForResponse option: '%s'

What it means

Raw parser error surfaced (wrapped) by page.waitForResponse(url, opts): while iterating the keys of the opts object, a key other than 'timeout' was found. This is the specific cause behind the 'parsing waitForResponse options' wrapper and identifies the exact offending key name.

Solutions

  1. Delete every key except 'timeout' from the waitForResponse options object.
  2. Build per-API option objects instead of sharing one across waitForFunction/waitForResponse/waitForRequest.
  3. Spread-filter explicitly: { timeout: shared.timeout }.
  4. Rely on page.setDefaultTimeout so no per-call options are needed.

Example fix

// before
const opts = { timeout: 5000, polling: 100 };
await page.waitForResponse('**/x', opts);

// after
await page.waitForResponse('**/x', { timeout: opts.timeout });
Defensive patterns

Strategy: validation

Validate before calling

function assertWaitForResponseKeys(opts) {
  const extra = Object.keys(opts ?? {}).filter(k => k !== 'timeout');
  if (extra.length) throw new Error(`unsupported waitForResponse option(s): ${extra.join(', ')}`);
}
assertWaitForResponseKeys(sharedOpts);
await page.waitForResponse('**/x', { timeout: sharedOpts.timeout });

Type guard

const hasOnlyTimeout = (o) => o == null || Object.keys(o).every(k => k === 'timeout');

Prevention

When it happens

Trigger: Any opts object with an extra key: page.waitForResponse(url, { timeout: 5000, polling: 'raf' }), { predicate: fn }, { headers: {...} }, or inherited/prototype-polluted keys visible to obj.Keys().

Common situations: Spreading a shared options object into multiple waitFor* calls where only some keys are valid per API; IDE autocompleting Playwright option names; stale options from older script versions.

Related errors


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/dd2d8634af6aab56. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/page_mapping.go:1120

	return wnopts, nil
}

func parsePageWaitForResponseOptions(
	ctx context.Context, opts sobek.Value, defaultTimeout time.Duration,
) (*common.PageWaitForResponseOptions, error) {
	ropts := common.NewPageWaitForResponseOptions(defaultTimeout)
	if k6common.IsNullish(opts) {
		return ropts, nil
	}

	rt := k6ext.Runtime(ctx)
	obj := opts.ToObject(rt)
	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 waitForResponse option: '%s'", k)
		}
	}

	return ropts, nil
}

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))

View on GitHub (pinned to 8d06114777)