{"record":{"id":"31b59bd799c31650","repo":"vitest-dev/vitest","slug":"cdp-is-not-supported-by-the-provider-provider-n","errorCode":null,"errorMessage":"CDP is not supported by the provider \"${provider.name}\".","messagePattern":"CDP is not supported by the provider \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser/src/node/projectParent.ts","lineNumber":208,"sourceCode":"  private cdpSessionsPromises = new Map<string, Promise<CDPSession>>()\n\n  async ensureCDPHandler(sessionId: string, rpcId: string): Promise<BrowserServerCDPHandler> {\n    const cachedHandler = this.cdps.get(rpcId)\n    if (cachedHandler) {\n      return cachedHandler\n    }\n    const browserSession = this.vitest._browserSessions.getSession(sessionId)\n    if (!browserSession) {\n      throw new Error(`Session \"${sessionId}\" not found.`)\n    }\n\n    const browser = browserSession.project.browser!\n    const provider = browser.provider\n    if (!provider) {\n      throw new Error(`Browser provider is not defined for the project \"${browserSession.project.name}\".`)\n    }\n    if (!provider.getCDPSession) {\n      throw new Error(`CDP is not supported by the provider \"${provider.name}\".`)\n    }\n\n    const session = await this.cdpSessionsPromises.get(rpcId) ?? await (async () => {\n      const promise = provider.getCDPSession!(sessionId).finally(() => {\n        this.cdpSessionsPromises.delete(rpcId)\n      })\n      this.cdpSessionsPromises.set(rpcId, promise)\n      return promise\n    })()\n\n    const rpc = (browser.state as BrowserServerState).testers.get(rpcId)\n    if (!rpc) {\n      throw new Error(`Tester RPC \"${rpcId}\" was not established.`)\n    }\n\n    const handler = new BrowserServerCDPHandler(session, rpc)\n    this.cdps.set(\n      rpcId,","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/browser/src/node/projectParent.ts#L190-L226","documentation":"ensureCDPHandler requires provider.getCDPSession to exist. Not every browser provider implements CDP: the preview provider and some WebDriverIO configurations do not expose getCDPSession, so requesting CDP through them is unsupported.","triggerScenarios":"Calling CDP tooling (the browser UI's network inspector, custom CDP commands, the serverTester CDP path) while using provider: 'preview', or a webdriverio setup that does not wire CDP. The check `if (!provider.getCDPSession)` is what gates this.","commonSituations":"Defaulting to the preview provider and then trying to use CDP-based debugging; switching providers without realising the new one lacks CDP; using a third-party provider that does not implement the optional getCDPSession method.","solutions":["Switch to a provider that supports CDP (typically playwright) if you need CDP debugging.","Avoid CDP-dependent APIs (browser command 'cdp', the devtools panel) when on the preview provider.","If authoring a custom provider and CDP is required, implement getCDPSession(sessionId) on the provider class."],"exampleFix":"// before\nbrowser: { provider: 'preview' } // then call cdp APIs\n// after\nbrowser: { provider: 'playwright' }","handlingStrategy":"type-guard","validationCode":"function providerSupportsCdp(provider?: { getCDPSession?: unknown }): boolean {\n  return !!provider && typeof provider.getCDPSession === 'function'\n}","typeGuard":"function isCdpCapable(provider: unknown): provider is { getCDPSession(sessionId: string): Promise<unknown> } {\n  return !!provider && typeof (provider as any).getCDPSession === 'function'\n}","tryCatchPattern":null,"preventionTips":["Use playwright when CDP debugging is required.","Branch on provider.getCDPSession existence before issuing CDP calls.","Document provider capabilities in your test harness."],"tags":["cdp","browser-provider","capability","browser"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}