{"record":{"id":"140491c4ae42ac77","repo":"d2lang/d2","slug":"failed-to-launch-chromium-w","errorCode":null,"errorMessage":"failed to launch Chromium: %w","messagePattern":"failed to launch Chromium: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"lib/png/png.go","lineNumber":62,"sourceCode":"\t\treturn fmt.Errorf(\"failed to stop Playwright: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc startPlaywright(pw *playwright.Playwright) (Playwright, error) {\n\t// Optimizations for a very tightly scoped Playwright instance\n\tbrowser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{\n\t\tArgs: []string{\n\t\t\t\"--no-sandbox\",                             // Removes security overhead\n\t\t\t\"--disable-dev-shm-usage\",                  // Prevents /dev/shm issues\n\t\t\t\"--disable-background-timer-throttling\",    // Prevents CPU throttling\n\t\t\t\"--disable-backgrounding-occluded-windows\", // Keeps rendering active\n\t\t\t\"--disable-features=TranslateUI\",           // Reduces feature overhead\n\t\t\t\"--disable-ipc-flooding-protection\",        // Removes IPC limits\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn Playwright{}, fmt.Errorf(\"failed to launch Chromium: %w\", err)\n\t}\n\tcontext, err := browser.NewContext(playwright.BrowserNewContextOptions{\n\t\tDeviceScaleFactor: playwright.Float(2.0),\n\t})\n\tif err != nil {\n\t\treturn Playwright{}, fmt.Errorf(\"failed to start new Playwright browser context: %w\", err)\n\t}\n\tpage, err := context.NewPage()\n\tif err != nil {\n\t\treturn Playwright{}, fmt.Errorf(\"failed to start new Playwright page: %w\", err)\n\t}\n\treturn Playwright{\n\t\tPW:      pw,\n\t\tBrowser: browser,\n\t\tPage:    page,\n\t}, nil\n}\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/lib/png/png.go#L44-L80","documentation":"startPlaywright launches a tuned headless Chromium instance via playwright-go. If browserType.Launch fails, this error wraps the driver's message. This is the entry point for browser lifecycle (RestartBrowser, InitPlaywright, InitPlaywrightWithPrompt), so any launch failure blocks all rendering work.","triggerScenarios":"Chromium fails to launch: browser executable not installed (missing `playwright install`), unsupported OS/arch, missing shared libraries on the host, sandbox/permission failures in containers, or driver version mismatch.","commonSituations":"Fresh CI containers or slim Docker images without browser dependencies; running as root without --no-sandbox adjustments; memory limits preventing Chromium startup; upgrading playwright-go without reinstalling browsers.","solutions":["Run the Playwright browser install step (playwright-go: playwright.Run with Install option or `go run github.com/playwright-community/playwright-go/cmd/playwright install`)","Install OS dependencies for Chromium (libnss3, libatk, etc.) or use the official Playwright base image","Add container-friendly launch flags (--no-sandbox, --disable-dev-shm-usage) or run with adequate /dev/shm and memory","Verify driver/browser versions match your playwright-go release and inspect the wrapped driver error for the exact cause"],"exampleFix":"// before\npw, err := playwright.Run()\nbrowser, err := browserType.Launch(opts)\n// after\npw, err := playwright.Run(playwright.BrowsersPath(\"/ms-playwright\"))\nerr = pw.Install() // ensure browsers present\nbrowser, err := browserType.Launch(opts)","handlingStrategy":"fallback","validationCode":"// Fail fast if browsers are missing\npw, err := playwright.Run()\nif err != nil {\n\treturn fmt.Errorf(\"playwright driver missing: %w — run playwright install\", err)\n}","typeGuard":null,"tryCatchPattern":"if pw, err := InitPlaywright(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to launch Chromium\") {\n\t\t// check executable exists, install browsers, then retry with backoff\n\t}\n}","preventionTips":["Install Playwright browsers in every image/CI step that runs the bundler","Use the official Playwright Docker base image or install OS deps (libnss3, libatk, ...)","Add container flags: --no-sandbox, --disable-dev-shm-usage; give /dev/shm enough space","Pin playwright-go and browser versions together; reinstall after upgrades"],"tags":["playwright","chromium","launch","environment","go"],"backgroundTag":"chromium-launch-failed","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}