{"record":{"id":"4f6880932cbb52c0","repo":"grafana/k6","slug":"unknown-error-code-s","errorCode":null,"errorMessage":"unknown error code: %s","messagePattern":"unknown error code: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/network_manager.go","lineNumber":914,"sourceCode":"// Authenticate sets HTTP authentication credentials to use.\nfunc (m *NetworkManager) Authenticate(credentials Credentials) error {\n\tm.credentials = credentials\n\tif !credentials.IsEmpty() {\n\t\tm.userReqInterceptionEnabled = true\n\t}\n\tif err := m.updateProtocolRequestInterception(); err != nil {\n\t\treturn fmt.Errorf(\"setting authentication credentials: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (m *NetworkManager) AbortRequest(requestID fetch.RequestID, errorReason string) error {\n\tm.logger.Debugf(\"NetworkManager:AbortRequest\", \"aborting request (id: %s, errorReason: %s)\",\n\t\trequestID, errorReason)\n\tnetErrorReason, ok := m.errorReasons[errorReason]\n\tif !ok {\n\t\treturn fmt.Errorf(\"unknown error code: %s\", errorReason)\n\t}\n\n\taction := fetch.FailRequest(requestID, netErrorReason)\n\tif err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {\n\t\t// Avoid logging as error when context is canceled.\n\t\t// Most probably this happens when trying to fail a site's background request\n\t\t// while the iteration is ending and therefore the browser context is being closed.\n\t\tif errors.Is(err, context.Canceled) {\n\t\t\tm.logger.Debug(\"NetworkManager:AbortRequest\", \"context canceled interrupting request\")\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"fail to abort request (id: %s): %w\", requestID, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (m *NetworkManager) ContinueRequest(","sourceCodeStart":896,"sourceCodeEnd":932,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/network_manager.go#L896-L932","documentation":"AbortRequest maps the given error reason string to a CDP network.ErrorReason via a fixed map (network_manager.go:144-161) and the supplied string is not a key. This is a script validation error: the reason you passed to route.abort() is misspelled or unsupported.","triggerScenarios":"Calling route.abort(reason) (or the mapping that invokes AbortRequest) with anything outside the allowed set: aborted, accessdenied, addressunreachable, blockedbyclient, blockedbyresponse, connectionaborted, connectionclosed, connectionfailed, connectionrefused, connectionreset, internetdisconnected, namenotresolved, timedout, failed. Case matters: 'Aborted' or 'aborted ' (with different casing/whitespace) will fail.","commonSituations":"Copy-pasting Puppeteer/Playwright reason strings that k6 doesn't use; using custom reasons like 'blocked' expecting them to work; typos ('conectionrefused').","solutions":["Use one of the 14 documented reasons, most commonly 'aborted' for a plain cancel","Check exact casing and spelling against the list in the k6 browser route.abort() docs (they match the map above)","If you need a custom outcome, abort with 'aborted' and assert on your own script state instead of inventing a reason"],"exampleFix":"// before\nawait route.abort('cancelled'); // not a valid reason\n\n// after\nawait route.abort('aborted'); // valid: aborted|accessdenied|addressunreachable|blockedbyclient|blockedbyresponse|connectionaborted|connectionclosed|connectionfailed|connectionrefused|connectionreset|internetdisconnected|namenotresolved|timedout|failed","handlingStrategy":"type-guard","validationCode":"const REASONS = new Set(['aborted','accessdenied','addressunreachable','blockedbyclient','blockedbyresponse','connectionaborted','connectionclosed','connectionfailed','connectionrefused','connectionreset','internetdisconnected','namenotresolved','timedout','failed']);","typeGuard":"function isAbortReason(r) {\n  return typeof r === 'string' && REASONS.has(r);\n}","tryCatchPattern":"if (!isAbortReason(reason)) { throw new Error(`invalid abort reason ${reason}`); }\nawait route.abort(reason);","preventionTips":["Centralize abort reasons as constants instead of inline strings","Run k6 lint/test on scripts that enumerate reasons via a Set lookup","Remember the list is case-sensitive and fixed — custom reasons are not supported"],"tags":["browser","route","abort","validation","script-bug"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}