{"record":{"id":"dd2d8634af6aab56","repo":"grafana/k6","slug":"unsupported-waitforresponse-option-s","errorCode":null,"errorMessage":"unsupported waitForResponse option: '%s'","messagePattern":"unsupported waitForResponse option: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":1120,"sourceCode":"\treturn wnopts, nil\n}\n\nfunc parsePageWaitForResponseOptions(\n\tctx context.Context, opts sobek.Value, defaultTimeout time.Duration,\n) (*common.PageWaitForResponseOptions, error) {\n\tropts := common.NewPageWaitForResponseOptions(defaultTimeout)\n\tif k6common.IsNullish(opts) {\n\t\treturn ropts, nil\n\t}\n\n\trt := k6ext.Runtime(ctx)\n\tobj := opts.ToObject(rt)\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 waitForResponse option: '%s'\", k)\n\t\t}\n\t}\n\n\treturn ropts, nil\n}\n\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))","sourceCodeStart":1102,"sourceCodeEnd":1138,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/page_mapping.go#L1102-L1138","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","solutions":["Delete every key except 'timeout' from the waitForResponse options object.","Build per-API option objects instead of sharing one across waitForFunction/waitForResponse/waitForRequest.","Spread-filter explicitly: { timeout: shared.timeout }.","Rely on page.setDefaultTimeout so no per-call options are needed."],"exampleFix":"// before\nconst opts = { timeout: 5000, polling: 100 };\nawait page.waitForResponse('**/x', opts);\n\n// after\nawait page.waitForResponse('**/x', { timeout: opts.timeout });","handlingStrategy":"validation","validationCode":"function assertWaitForResponseKeys(opts) {\n  const extra = Object.keys(opts ?? {}).filter(k => k !== 'timeout');\n  if (extra.length) throw new Error(`unsupported waitForResponse option(s): ${extra.join(', ')}`);\n}\nassertWaitForResponseKeys(sharedOpts);\nawait page.waitForResponse('**/x', { timeout: sharedOpts.timeout });","typeGuard":"const hasOnlyTimeout = (o) => o == null || Object.keys(o).every(k => k === 'timeout');","tryCatchPattern":null,"preventionTips":["Never spread shared option objects into waitForResponse; pick fields explicitly.","Treat 'timeout' as the only legal key when reviewing waitForResponse calls in PRs."],"tags":["k6","browser","options","waitforresponse","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"}