{"record":{"id":"3799a2da74e41148","repo":"grafana/k6","slug":"fail-to-abort-request-id-s-w","errorCode":null,"errorMessage":"fail to abort request (id: %s): %w","messagePattern":"fail to abort request \\(id: (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/network_manager.go","lineNumber":925,"sourceCode":"}\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(\n\trequestID fetch.RequestID,\n\topts ContinueOptions,\n\toriginalHeaders []HTTPHeader,\n) error {\n\tm.logger.Debugf(\"NetworkManager:ContinueRequest\", \"continuing request (id: %s)\", requestID)\n\taction := fetch.ContinueRequest(requestID)\n\n\tif len(opts.Headers) > 0 {\n\t\taction = action.WithHeaders(toFetchHeaders(opts.Headers))\n\t}\n\tif opts.URL != \"\" {","sourceCodeStart":907,"sourceCodeEnd":943,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/common/network_manager.go#L907-L943","documentation":"Failure of the CDP Fetch.failRequest command while aborting the identified intercepted request. Fires when the session rejects the command — commonly because the request already completed, the target navigated away, or the context was canceled during teardown (which is deliberately not logged as an error).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/network_manager.go:925 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Abort requests promptly in the route handler before they complete","Ignore context-canceled failures during iteration teardown","Check the request ID is still intercepted (Fetch domain active) when aborting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}