{"record":{"id":"cbd6cf25ec9a900d","repo":"grafana/k6","slug":"unsupported-waitforrequest-option-s","errorCode":null,"errorMessage":"unsupported waitForRequest option: '%s'","messagePattern":"unsupported waitForRequest option: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":1144,"sourceCode":"\nfunc parsePageWaitForRequestOptions(\n\tctx context.Context, opts sobek.Value, defaultTimeout time.Duration,\n) (*common.PageWaitForRequestOptions, error) {\n\tropts := common.PageWaitForRequestOptions{\n\t\tTimeout: defaultTimeout,\n\t}\n\n\tif k6common.IsNullish(opts) {\n\t\treturn &ropts, nil\n\t}\n\n\tobj := opts.ToObject(k6ext.Runtime(ctx))\n\tfor _, k := range obj.Keys() {\n\t\tswitch k {\n\t\tcase \"timeout\":\n\t\t\tropts.Timeout = time.Duration(obj.Get(k).ToInteger()) * time.Millisecond\n\t\tdefault:\n\t\t\treturn &ropts, fmt.Errorf(\"unsupported waitForRequest option: '%s'\", k)\n\t\t}\n\t}\n\n\treturn &ropts, nil\n}\n\nfunc parsePageWaitForEventOptions(\n\tctx context.Context, opts sobek.Value, defaultTimeout time.Duration,\n) (*common.PageWaitForEventOptions, sobek.Callable, error) {\n\tropts := &common.PageWaitForEventOptions{\n\t\tTimeout: defaultTimeout,\n\t}\n\n\tif k6common.IsNullish(opts) {\n\t\treturn ropts, nil, nil\n\t}\n\n\tif fn, ok := sobek.AssertFunction(opts); ok {","sourceCodeStart":1126,"sourceCodeEnd":1162,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/page_mapping.go#L1126-L1162","documentation":"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.","triggerScenarios":"page.waitForRequest(url, { timeout: 5000, url: '**/filter' }), { method: 'POST' }, { predicate: fn }, or any extra property on the second argument.","commonSituations":"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.","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)."],"exampleFix":"// before\nawait page.waitForRequest('**/submit', { method: 'POST' });\n\n// after\nawait page.waitForEvent('request', { predicate: r => r.method() === 'POST' && r.url().includes('/submit') });","handlingStrategy":"validation","validationCode":"function assertWaitForRequestKeys(opts) {\n  const extra = Object.keys(opts ?? {}).filter(k => k !== 'timeout');\n  if (extra.length) throw new Error(`unsupported waitForRequest option(s): ${extra.join(', ')}`);\n}\nassertWaitForRequestKeys({ timeout: 5000 });\nawait page.waitForRequest(/\\/submit/, { timeout: 5000 });","typeGuard":"const hasOnlyTimeoutKey = (o) => o == null || Object.keys(o).every(k => k === 'timeout');","tryCatchPattern":null,"preventionTips":["Filter requests with a RegExp pattern or a waitForEvent predicate, not option keys.","Review migrated Playwright lines that pass method/headers to waitForRequest."],"tags":["k6","browser","options","waitforrequest","argument-validation"],"backgroundTag":"invalid-options-object","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}