{"record":{"id":"c4fef2fdcca54fe4","repo":"microsoft/playwright","slug":"connecting-to-channel-by-channel-name-is-not-su","errorCode":null,"errorMessage":"Connecting to ${channel} by channel name is not supported on ${process.platform}.","messagePattern":"Connecting to (.+?) by channel name is not supported on (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/chromium/chromium.ts","lineNumber":480,"sourceCode":"  const url = new URL(endpointURL);\n  if (!url.pathname.endsWith('/'))\n    url.pathname += '/';\n  url.pathname += 'json/version/';\n  const httpURL = url.toString();\n\n  const json = await fetchData(progress, {\n    url: httpURL,\n    headers,\n  }, async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\\n` +\n    `This does not look like a DevTools server, try connecting via ws://.`)\n  );\n  return JSON.parse(json).webSocketDebuggerUrl;\n}\n\nasync function resolveChannelEndpoint(progress: Progress, channel: string): Promise<string> {\n  const userDataDir = defaultUserDataDirForChannel(channel);\n  if (!userDataDir)\n    throw new Error(`Connecting to ${channel} by channel name is not supported on ${process.platform}.`);\n\n  const devToolsActivePortPath = path.join(userDataDir, 'DevToolsActivePort');\n  progress.log(`<ws preparing> reading ${devToolsActivePortPath}`);\n\n  const contents = await progress.race(fs.promises.readFile(devToolsActivePortPath, 'utf-8').catch(() => undefined));\n  if (!contents) {\n    throw new Error(\n        `Could not connect to ${channel}: DevToolsActivePort file not found at ${devToolsActivePortPath}.\\n` +\n        remoteDebuggingHint(channel));\n  }\n\n  const port = parseInt(contents.trim(), 10);\n  if (isNaN(port))\n    throw new Error(`Could not connect to ${channel}: invalid DevToolsActivePort file at ${devToolsActivePortPath}.`);\n\n  const endpoint = `ws://localhost:${port}/devtools/browser`;\n  progress.log(`<ws preparing> resolved channel \"${channel}\" to ${endpoint}`);\n  return endpoint;","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/chromium/chromium.ts#L462-L498","documentation":"Thrown by resolveChannelEndpoint when defaultUserDataDirForChannel(channel) returns nothing for the current platform. Connecting by channel name requires Playwright to know where that channel writes its user-data directory on this OS; if it does not, the channel-by-name path is unsupported.","triggerScenarios":"await chromium.connectOverCDP('chrome') on a platform where the channel-to-userDataDir mapping is not defined (e.g. some Linux distros or uncommon channels).","commonSituations":"Cross-OS script that uses a channel name; works on macOS/Windows but throws on a Linux without a known profile path. Using a channel name that is not in the chromiumChannels registry for this platform.","solutions":["Connect by explicit WebSocket URL instead of channel name: launch Chrome with --remote-debugging-port=9222 and chromium.connectOverCDP('http://localhost:9222').","Use a channel name that is supported on this platform, or fall back to launching Chromium through Playwright rather than attaching to a channel.","On unsupported OS, manage the user-data-dir yourself and expose the WS endpoint directly."],"exampleFix":"// before\nconst b = await chromium.connectOverCDP('chrome');\n// after (platform without channel mapping)\n// shell: chromium --remote-debugging-port=9222 --user-data-dir=/tmp/cdp\nconst b = await chromium.connectOverCDP('http://localhost:9222');","handlingStrategy":"validation","validationCode":"function assertChannelSupportedOnPlatform(channel: string) {\n  // channel-by-name connect needs a known userDataDir on this OS\n  const known = process.platform === 'win32' || process.platform === 'darwin'; // chrome/msedge profile paths\n  if (!known) throw new Error(`Channel '${channel}' connect not supported on ${process.platform}; use wsEndpoint URL`);\n}","typeGuard":"function channelConnectSupportedOnPlatform(): boolean {\n  return process.platform === 'win32' || process.platform === 'darwin';\n}","tryCatchPattern":null,"preventionTips":["On Linux, prefer connecting by explicit http/ws URL over channel name.","Make the connect target an explicit endpoint to stay platform-independent."],"tags":["cdp","connect","chromium","platform","channel"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}