{"record":{"id":"477aadfead88e24a","repo":"grafana/k6","slug":"clearing-cookies-w","errorCode":null,"errorMessage":"clearing cookies: %w","messagePattern":"clearing cookies: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/browser_context.go","lineNumber":513,"sourceCode":"\tsetCookies := storage.\n\t\tSetCookies(cookiesToSet).\n\t\tWithBrowserContextID(b.id)\n\tif err := setCookies.Do(cdp.WithExecutor(b.ctx, b.browser.conn)); err != nil {\n\t\treturn fmt.Errorf(\"cannot set cookies: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// ClearCookies clears cookies.\nfunc (b *BrowserContext) ClearCookies() error {\n\tb.logger.Debugf(\"BrowserContext:ClearCookies\", \"bctxid:%v\", b.id)\n\n\tclearCookies := storage.\n\t\tClearCookies().\n\t\tWithBrowserContextID(b.id)\n\tif err := clearCookies.Do(cdp.WithExecutor(b.ctx, b.browser.conn)); err != nil {\n\t\treturn fmt.Errorf(\"clearing cookies: %w\", err)\n\t}\n\treturn nil\n}\n\n// Cookies returns all cookies.\n// Some of them can be added with the AddCookies method and some of them are\n// automatically taken from the browser context when it is created. And some of\n// them are set by the page, i.e., using the Set-Cookie HTTP header or via\n// JavaScript like document.cookie.\nfunc (b *BrowserContext) Cookies(urls ...string) ([]*Cookie, error) {\n\tb.logger.Debugf(\"BrowserContext:Cookies\", \"bctxid:%v\", b.id)\n\n\t// get cookies from this browser context.\n\tgetCookies := storage.\n\t\tGetCookies().\n\t\tWithBrowserContextID(b.id)\n\tnetworkCookies, err := getCookies.Do(\n\t\tcdp.WithExecutor(b.ctx, b.browser.conn),","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/browser_context.go#L495-L531","documentation":"The CDP Storage.clearCookies command failed for this browser context (context id echoed in debug logs). The wrapped error comes from the Chrome DevTools Protocol session — the browser may have closed, the context been destroyed, or the connection dropped mid-call.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/browser_context.go:513 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the browser/context is still open before calling clearCookies()","Retry after re-creating the browser context","Check for crashes or timeouts in earlier browser operations"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}