{"record":{"id":"890d6ac44e60e509","repo":"garrytan/gstack","slug":"xvfb-on-display-exited-during-startup-code-p","errorCode":null,"errorMessage":"Xvfb on ${display} exited during startup (code ${proc.exitCode}). Hint: install xvfb (apt-get install xvfb / yum install xorg-x11-server-Xvfb).","messagePattern":"Xvfb on (.+?) exited during startup \\(code (.+?)\\)\\. Hint: install xvfb \\(apt-get install xvfb / yum install xorg-x11-server-Xvfb\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browse/src/xvfb.ts","lineNumber":150,"sourceCode":"  const display = `:${displayNum}`;\n\n  // Spawn detached: Xvfb's lifetime is tied to whether we've explicitly\n  // killed it via the handle's close() method, not to the parent process.\n  const proc = Bun.spawn(['Xvfb', display, '-screen', '0', '1920x1080x24', '-ac'], {\n    stdio: ['ignore', 'ignore', 'ignore'],\n  });\n  proc.unref();\n\n  // Wait for the X server to become reachable — Xvfb takes a few hundred ms\n  // to bind. Probe via xdpyinfo with retries.\n  const deadline = Date.now() + 3000;\n  let ready = false;\n  while (Date.now() < deadline) {\n    await Bun.sleep(100);\n    if (!isDisplayFree(displayNum)) { ready = true; break; }\n    // If Xvfb crashed during startup, fail fast.\n    if (proc.exitCode != null) {\n      throw new Error(`Xvfb on ${display} exited during startup (code ${proc.exitCode}). Hint: install xvfb (apt-get install xvfb / yum install xorg-x11-server-Xvfb).`);\n    }\n  }\n  if (!ready) {\n    try { proc.kill('SIGKILL'); } catch { /* ignore */ }\n    throw new Error(`Xvfb on ${display} never became reachable within 3s timeout`);\n  }\n\n  const startTime = readPidStartTime(proc.pid);\n  return {\n    pid: proc.pid,\n    startTime,\n    display,\n    close: () => cleanupXvfb({ pid: proc.pid, startTime, display }),\n  };\n}\n\n/**\n * Cleanup an Xvfb child if it's still ours. Validates ownership first; if","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/xvfb.ts#L132-L168","documentation":"Error \"Xvfb on ${display} exited during startup (code ${proc.exitCode}). Hint: install xvfb (apt-get install xvfb / yum install xorg-x11-server-Xvfb).\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/xvfb.ts:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}