saadeghi/daisyui · error · Error

Chrome page creation failed with HTTP ${response.status}

Error message

Chrome page creation failed with HTTP ${response.status}

What it means

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.

Source

Thrown at packages/tailwind-play-share/index.mjs:421

  close() {
    if (this.socket.readyState === WebSocket.OPEN) this.socket.close()
  }
}

async function getPageWebSocketUrl(port) {
  const endpoint = `http://127.0.0.1:${port}`
  let response = await fetch(`${endpoint}/json/list`)
  if (!response.ok) throw new Error(`Chrome target discovery failed with HTTP ${response.status}`)

  let targets = await response.json()
  let page = targets.find((target) => target.type === "page" && target.webSocketDebuggerUrl)

  if (!page) {
    response = await fetch(`${endpoint}/json/new?${encodeURIComponent("about:blank")}`, {
      method: "PUT",
    })
    if (!response.ok) throw new Error(`Chrome page creation failed with HTTP ${response.status}`)
    page = await response.json()
  }

  if (!page.webSocketDebuggerUrl) throw new Error("Chrome did not expose a page DevTools socket")
  return page.webSocketDebuggerUrl
}

async function evaluate(client, expression) {
  const response = await client.send("Runtime.evaluate", {
    awaitPromise: true,
    expression,
    returnByValue: true,
    userGesture: true,
  })

  if (response.exceptionDetails) {
    const description =
      response.exceptionDetails.exception?.description ??

View on GitHub (pinned to 42b09e637e)

Solutions

  1. 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.
  2. Pass an explicit --browser path to a Chromium build you have verified, e.g. TAILWIND_PLAY_BROWSER=/usr/bin/chromium.
  3. Run with --headed to rule out headless=new target-creation restrictions.
  4. Retry the whole createTailwindPlay call: the launched Chrome process and profile are torn down each attempt, so a transient 500 often clears.

Example fix

// before
const url = await createTailwindPlay({ html, css })

// after
async function createWithRetry(inputs, attempts = 3) {
  let lastError
  for (let i = 0; i < attempts; i++) {
    try {
      return await createTailwindPlay(inputs)
    } catch (error) {
      lastError = error
      if (!/Chrome page creation failed with HTTP/.test(error.message)) throw error
    }
  }
  throw lastError
}
Defensive patterns

Strategy: retry

Validate before calling

// Before calling createTailwindPlay, sanity-check the Chrome DevTools HTTP surface
// of the executable you will use (best-effort; the real check happens inside).
import { spawn } from "node:child_process"

async function canCreateTarget(executable) {
  // returns true if a quick Chrome boot can create a page target
  return true // no public pre-check; rely on retry instead
}

Try / catch

try {
  url = await createTailwindPlay({ html, css, browser })
} catch (error) {
  if (/Chrome page creation failed with HTTP \d+/.test(error.message) && attemptsLeft > 0) {
    continue // retry the whole call; profile + process reset each attempt
  }
  throw error
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13). Data as JSON: /api/errors/3ac13845a7dc14c2. Report an issue: GitHub.