{"record":{"id":"e118933a674679b7","repo":"grafana/k6","slug":"waitforevent-does-not-support-option-s","errorCode":null,"errorMessage":"waitForEvent does not support option: '%s'","messagePattern":"waitForEvent does not support option: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":1180,"sourceCode":"\tif fn, ok := sobek.AssertFunction(opts); ok {\n\t\treturn ropts, fn, nil\n\t}\n\n\tobj := opts.ToObject(k6ext.Runtime(ctx))\n\n\tvar pred sobek.Callable\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\tcase \"predicate\":\n\t\t\tfn, ok := sobek.AssertFunction(obj.Get(k))\n\t\t\tif !ok {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"predicate must be a function\")\n\t\t\t}\n\t\t\tpred = fn\n\t\tdefault:\n\t\t\treturn nil, nil, fmt.Errorf(\"waitForEvent does not support option: '%s'\", k)\n\t\t}\n\t}\n\n\treturn ropts, pred, nil\n}\n\n// parseSize parses the size options from a Sobek value.\nfunc parseSize(rt *sobek.Runtime, opts sobek.Value) (*common.Size, error) {\n\tsize := &common.Size{}\n\tif k6common.IsNullish(opts) {\n\t\treturn size, nil\n\t}\n\n\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tv := obj.Get(k)\n\t\tif k6common.IsNullish(v) {\n\t\t\tcontinue","sourceCodeStart":1162,"sourceCodeEnd":1198,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/page_mapping.go#L1162-L1198","documentation":"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'.","triggerScenarios":"page.waitForEvent('request', { url: '**/api', timeout: 5000 }) (url key unsupported); { headers: ... }, { method: ... }, or any Playwright-only filter key placed in the options object.","commonSituations":"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.","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."],"exampleFix":"// before\nawait page.waitForEvent('request', { url: '**/api/**' });\n\n// after\nawait page.waitForEvent('request', { predicate: e => /\\/api\\//.test(e.url()) });","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['timeout', 'predicate']);\nconst extra = Object.keys(opts ?? {}).filter(k => !ALLOWED.has(k));\nif (extra.length) throw new Error(`waitForEvent does not support: ${extra.join(', ')}`);\nawait page.waitForEvent('request', opts);","typeGuard":"const isWaitForEventOptions = (o) => o == null || (typeof o === 'object' && Object.keys(o).every(k => k === 'timeout' || k === 'predicate'));","tryCatchPattern":null,"preventionTips":["Encode URL/method filters in the predicate function body.","Keep a project-level constant of allowed keys per wait API and validate before calls."],"tags":["k6","browser","waitforevent","options","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"}