{"record":{"id":"056d977a24ccd9bf","repo":"d2lang/d2","slug":"failed-to-start-new-playwright-page-w","errorCode":null,"errorMessage":"failed to start new Playwright page: %w","messagePattern":"failed to start new Playwright page: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/png/png.go","lineNumber":72,"sourceCode":"\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\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()","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/lib/png/png.go#L54-L90","documentation":"startPlaywright finishes by opening a new page inside the browser context. If context.NewPage fails, this error wraps the driver's message. This is the last step of Playwright setup; failing here means the browser and context exist but no usable tab could be opened.","triggerScenarios":"context.NewPage returns a driver error — context/browser closed concurrently, browser crashed between NewContext and NewPage, or too many open pages/targets exhausting resources.","commonSituations":"Other goroutines closing the browser/page while startPlaywright runs; long-lived workers accumulating pages until Chromium refuses new targets; crashes from resource exhaustion in shared environments.","solutions":["Verify no concurrent RestartBrowser/Cleanup is racing the setup; serialize lifecycle access with a mutex","Check Chromium process count/pages in flight; close stale pages or restart the browser when targets are exhausted","Inspect the wrapped driver error for a crash message and address resource limits (memory, /dev/shm)","Retry the whole startPlaywright sequence once — transient driver hiccups often clear on retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"pw, err := startPlaywright(p)\nif err != nil {\n\tif strings.Contains(err.Error(), \"Playwright page\") {\n\t\t// close stale pages / restart browser, then retry startPlaywright once\n\t}\n}","preventionTips":["Limit concurrent open pages; close pages after each capture","Guard against concurrent Close/RestartBrowser during setup with a mutex","Bound page accumulation in long-lived workers; recycle the browser periodically","Watch Chromium resource limits (memory, file descriptors) in production"],"tags":["playwright","page","chromium","lifecycle","go"],"backgroundTag":"browser-page-creation-failed","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}