{"record":{"id":"3ac13845a7dc14c2","repo":"saadeghi/daisyui","slug":"chrome-page-creation-failed-with-http-response-s","errorCode":null,"errorMessage":"Chrome page creation failed with HTTP ${response.status}","messagePattern":"Chrome page creation failed with HTTP (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/index.mjs","lineNumber":421,"sourceCode":"\n  close() {\n    if (this.socket.readyState === WebSocket.OPEN) this.socket.close()\n  }\n}\n\nasync function getPageWebSocketUrl(port) {\n  const endpoint = `http://127.0.0.1:${port}`\n  let response = await fetch(`${endpoint}/json/list`)\n  if (!response.ok) throw new Error(`Chrome target discovery failed with HTTP ${response.status}`)\n\n  let targets = await response.json()\n  let page = targets.find((target) => target.type === \"page\" && target.webSocketDebuggerUrl)\n\n  if (!page) {\n    response = await fetch(`${endpoint}/json/new?${encodeURIComponent(\"about:blank\")}`, {\n      method: \"PUT\",\n    })\n    if (!response.ok) throw new Error(`Chrome page creation failed with HTTP ${response.status}`)\n    page = await response.json()\n  }\n\n  if (!page.webSocketDebuggerUrl) throw new Error(\"Chrome did not expose a page DevTools socket\")\n  return page.webSocketDebuggerUrl\n}\n\nasync function evaluate(client, expression) {\n  const response = await client.send(\"Runtime.evaluate\", {\n    awaitPromise: true,\n    expression,\n    returnByValue: true,\n    userGesture: true,\n  })\n\n  if (response.exceptionDetails) {\n    const description =\n      response.exceptionDetails.exception?.description ??","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/index.mjs#L403-L439","documentation":"Thrown by getPageWebSocketUrl after the script found no existing page target and attempted to create one with a PUT to Chrome's /json/new?about:blank DevTools HTTP endpoint, but Chrome answered with a non-2xx HTTP status. This is the CDP target-creation step that runs after the DevTools port is known and before a WebSocket client is attached.","triggerScenarios":"fetch(`http://127.0.0.1:${port}/json/new?about%2Fblank`, { method: \"PUT\" }) returns a response where response.ok is false (e.g. 403, 404, 500). This happens when Chrome refuses to open a new page target via the HTTP endpoint.","commonSituations":"Chrome version that deprecated the PUT method on /json/new (newer Chrome prefers POST or a different path), a managed/policy-locked Chrome build that blocks target creation, headless=new mode refusing the endpoint, or the browser being mid-shutdown so the HTTP server returns 500.","solutions":["Upgrade or downgrade Chrome/Chromium to a version known to support PUT /json/new (stable Chrome 120+ generally works); the script has no fallback method.","Pass an explicit --browser path to a Chromium build you have verified, e.g. TAILWIND_PLAY_BROWSER=/usr/bin/chromium.","Run with --headed to rule out headless=new target-creation restrictions.","Retry the whole createTailwindPlay call: the launched Chrome process and profile are torn down each attempt, so a transient 500 often clears."],"exampleFix":"// before\nconst url = await createTailwindPlay({ html, css })\n\n// after\nasync function createWithRetry(inputs, attempts = 3) {\n  let lastError\n  for (let i = 0; i < attempts; i++) {\n    try {\n      return await createTailwindPlay(inputs)\n    } catch (error) {\n      lastError = error\n      if (!/Chrome page creation failed with HTTP/.test(error.message)) throw error\n    }\n  }\n  throw lastError\n}","handlingStrategy":"retry","validationCode":"// Before calling createTailwindPlay, sanity-check the Chrome DevTools HTTP surface\n// of the executable you will use (best-effort; the real check happens inside).\nimport { spawn } from \"node:child_process\"\n\nasync function canCreateTarget(executable) {\n  // returns true if a quick Chrome boot can create a page target\n  return true // no public pre-check; rely on retry instead\n}","typeGuard":null,"tryCatchPattern":"try {\n  url = await createTailwindPlay({ html, css, browser })\n} catch (error) {\n  if (/Chrome page creation failed with HTTP \\d+/.test(error.message) && attemptsLeft > 0) {\n    continue // retry the whole call; profile + process reset each attempt\n  }\n  throw error\n}","preventionTips":["Pin a Chrome/Chromium version known to support the /json/new HTTP endpoint.","Pass --browser explicitly rather than relying on auto-detection in CI.","Wrap createTailwindPlay in a small retry loop for transient HTTP failures."],"tags":["chrome-devtools","cdp","http","browser-automation"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}