{"record":{"id":"952fcb7b32efeba4","repo":"d2lang/d2","slug":"failed-to-install-playwright-w","errorCode":null,"errorMessage":"failed to install Playwright: %w","messagePattern":"failed to install Playwright: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/png/png.go","lineNumber":87,"sourceCode":"\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\nfunc InitPlaywright() (Playwright, error) {\n\terr := playwright.Install(&playwright.RunOptions{\n\t\tVerbose:  false,\n\t\tBrowsers: []string{\"chromium\"},\n\t})\n\tif err != nil {\n\t\treturn Playwright{}, fmt.Errorf(\"failed to install Playwright: %w\", err)\n\t}\n\n\tpw, err := playwright.Run()\n\tif err != nil {\n\t\treturn Playwright{}, fmt.Errorf(\"failed to run Playwright: %w\", err)\n\t}\n\treturn startPlaywright(pw)\n}\n\nfunc InitPlaywrightWithPrompt() (Playwright, error) {\n\tif os.Getenv(\"CI\") != \"\" {\n\t\treturn InitPlaywright()\n\t}\n\n\t// Just try running first. This only works if drivers and browsers are already installed\n\tpw, err := playwright.Run()\n\tif err == nil {\n\t\treturn startPlaywright(pw)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/lib/png/png.go#L69-L105","documentation":"InitPlaywright wraps any error from playwright.Install() (which downloads the Chromium browser binary) with this message. The library calls it to ensure Chromium v149 is available before rendering non-SVG images. It indicates the browser download/install step failed, and the underlying cause is preserved via %w.","triggerScenarios":"Calling InitPlaywright() or InitPlaywrightWithPrompt() when playwright.Install(&playwright.RunOptions{Browsers:[\"chromium\"]}) fails: no network access, download interrupted, insufficient disk space, or unwritable playwright cache directory (e.g. ~/.cache/ms-playwright).","commonSituations":"CI containers with no internet egress or restricted DNS; corporate proxies blocking the CDN; read-only HOME in sandboxes/Docker; disk full; TLS interception breaking the download.","solutions":["Check network connectivity/proxy settings and retry; set HTTPS_PROXY if behind a corporate proxy","Ensure the playwright browser cache directory is writable (check $HOME or PLAYWRIGHT_BROWSERS_PATH)","Free disk space; Chromium download needs several hundred MB","Pre-install the browser manually (playwright install chromium) and re-run","Inspect the wrapped cause (%w) for the precise driver error"],"exampleFix":"// before\npw, err := InitPlaywright()\nif err != nil { log.Fatal(err) }\n// after\nif err := os.Setenv(\"PLAYWRIGHT_BROWSERS_PATH\", \"/tmp/pw-browsers\"); err != nil { log.Fatal(err) }\npw, err := InitPlaywright()\nif err != nil { log.Fatalf(\"playwright init: %v (check network/disk)\", err) }","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(browserCacheDir()); err != nil && !hasNetwork() { t.Skip(\"no network for playwright install\") }","typeGuard":"var pwe *playwright.Error // inspect wrapped cause\nfunc installCause(err error) error { return errors.Unwrap(err) }","tryCatchPattern":"pw, err := InitPlaywright()\nif err != nil {\n    var dlErr error\n    if errors.Is(err, context.DeadlineExceeded) { /* retry with proxy */ }\n    _ = dlErr\n    log.Printf(\"playwright install failed: %v\", err)\n    return fallbackSVGRendering()\n}","preventionTips":["Pre-install browsers in CI images so install is a no-op","Set PLAYWRIGHT_BROWSERS_PATH to a writable dir","Verify disk space (>1GB) before rendering","Set HTTPS_PROXY/NO_PROXY for corporate networks"],"tags":["go","playwright","chromium","installation","network"],"backgroundTag":"browser-install-failed","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}