{"record":{"id":"e60d7cb13ba747b2","repo":"microsoft/playwright","slug":"cdp-session-is-only-available-in-chromium-e60d7c","errorCode":null,"errorMessage":"CDP session is only available in Chromium","messagePattern":"CDP session is only available in Chromium","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/dispatchers/browserDispatcher.ts","lineNumber":115,"sourceCode":"    if (this._options.ignoreStopAndKill)\n      return;\n    await this._object.close(progress, params);\n  }\n\n  async killForTests(params: channels.BrowserKillForTestsParams, progress: Progress): Promise<void> {\n    if (this._options.ignoreStopAndKill)\n      return;\n    await this._object.killForTests(progress);\n  }\n\n  async defaultUserAgentForTest(): Promise<channels.BrowserDefaultUserAgentForTestResult> {\n    return { userAgent: this._object.userAgent() };\n  }\n\n  async newBrowserCDPSession(params: channels.BrowserNewBrowserCDPSessionParams, progress: Progress): Promise<channels.BrowserNewBrowserCDPSessionResult> {\n    // Note: progress is ignored because this operation is not cancellable and should not block in the browser anyway.\n    if (this._object.options.browserType !== 'chromium')\n      throw new Error(`CDP session is only available in Chromium`);\n    const crBrowser = this._object as CRBrowser;\n    return { session: new CDPSessionDispatcher(this, await progress.race(crBrowser.newBrowserCDPSession())) };\n  }\n\n  async startTracing(params: channels.BrowserStartTracingParams, progress: Progress): Promise<void> {\n    // Note: progress is ignored because this operation is not cancellable and should not block in the browser anyway.\n    if (this._object.options.browserType !== 'chromium')\n      throw new Error(`Tracing is only available in Chromium`);\n    const crBrowser = this._object as CRBrowser;\n    await progress.race(crBrowser.startTracing(params.page ? (params.page as PageDispatcher)._object : undefined, params));\n  }\n\n  async stopTracing(params: channels.BrowserStopTracingParams, progress: Progress): Promise<channels.BrowserStopTracingResult> {\n    // Note: progress is ignored because this operation is not cancellable and should not block in the browser anyway.\n    if (this._object.options.browserType !== 'chromium')\n      throw new Error(`Tracing is only available in Chromium`);\n    const crBrowser = this._object as CRBrowser;\n    return { artifact: ArtifactDispatcher.from(this, await progress.race(crBrowser.stopTracing())) };","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/dispatchers/browserDispatcher.ts#L97-L133","documentation":"Thrown by BrowserDispatcher.newBrowserCDPSession() when the browser's browserType is not chromium. This is the browser-level (not page/frame) CDP session, used for browser-wide DevTools targets; like the context variant it is Chromium-only and rejected for firefox/webkit before any CDP work begins.","triggerScenarios":"Calling browser.newBrowserCDPSession() on a firefox or webkit browser object: e.g. const browser = await firefox.launch(); await browser.newBrowserCDPSession();. Cross-browser helpers that unconditionally open a browser-level CDP channel hit this on non-chromium projects.","commonSituations":"Tooling that uses browser-level CDP (e.g. to enumerate targets, browser-wide tracing/permissions) and is run against the firefox/webkit projects; tests assumed to be chromium-only that later got multi-browser config.","solutions":["Gate the call on browserType name: if (browser.browserType().name() === 'chromium') { const cdp = await browser.newBrowserCDPSession(); }.","Scope the test/project to chromium when it depends on browser-level CDP.","Prefer context/page-level Playwright APIs that work cross-browser where they exist."],"exampleFix":"// before: throws on firefox/webkit\nconst cdp = await browser.newBrowserCDPSession();\n\n// after: chromium guard\nif (browser.browserType().name() !== 'chromium')\n  test.skip();\nconst cdp = await browser.newBrowserCDPSession();","handlingStrategy":"type-guard","validationCode":"if (browser.browserType().name() !== 'chromium') {\n  throw new Error('browser.newBrowserCDPSession() requires chromium');\n}","typeGuard":"function isChromiumBrowser(b): b is Browser {\n  return b.browserType().name() === 'chromium';\n}","tryCatchPattern":null,"preventionTips":["Branch on browserType().name() before opening a browser-level CDP session.","Restrict browser-level-CDP tests to the chromium project.","Document which helpers are chromium-only so they are not reused on firefox/webkit."],"tags":["cdp","chromium","browser","browser-type"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}