{"record":{"id":"50e32abcb8724a4b","repo":"srbhr/Resume-Matcher","slug":"pdf-renderer-failed-to-initialize","errorCode":null,"errorMessage":"PDF renderer failed to initialize.","messagePattern":"PDF renderer failed to initialize\\.","errorType":"exception","errorClass":"PDFRenderError","httpStatus":null,"severity":"error","filePath":"apps/backend/app/pdf.py","lineNumber":333,"sourceCode":"        try:\n            await init_pdf_renderer()\n        except NotImplementedError:\n            async with _subprocess_lock:\n                _subprocess_supported = False\n            subprocess_supported = False\n        except PlaywrightError as e:\n            _raise_playwright_error(e, url)\n\n    if not subprocess_supported:\n        try:\n            return await _render_resume_pdf_in_thread(\n                url, selector, pdf_format, pdf_margins\n            )\n        except PlaywrightError as e:\n            _raise_playwright_error(e, url)\n\n    if _browser is None:\n        raise PDFRenderError(\"PDF renderer failed to initialize.\")\n\n    try:\n        return await _render_with_browser(_browser, url, selector, pdf_format, pdf_margins)\n    except PlaywrightError as e:\n        _raise_playwright_error(e, url)\n","sourceCodeStart":315,"sourceCodeEnd":339,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/pdf.py#L315-L339","documentation":"PDFRenderError raised in render_resume_pdf when the module-level lazy-initialized `_browser` is still None after the init path ran, meaning the renderer never successfully started. It guards the render call against using an uninitialized Playwright browser instance.","triggerScenarios":"render_resume_pdf is called but `_browser` remains None because the lazy init (get/launch browser) failed or was skipped, and the failure path didn't already raise a more specific error.","commonSituations":"First PDF request arriving before/while browser initialization failed; Playwright runtime missing browsers in a fresh deploy; init exception swallowed in the init helper; concurrent requests racing an in-progress init that failed.","solutions":["Check earlier server logs for the underlying Playwright launch failure (missing executable, launch timeout)","Run `<python> -m playwright install chromium` in the deployment environment","Restart the backend so lazy init retries on the next request","Add retry/init-failure propagation around the browser initialization step","Ensure only the app's event loop policy allows subprocesses (_loop_supports_subprocess) so init can run on Windows"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"from app import pdf\ndef renderer_ready() -> bool:\n    return pdf._browser is not None","typeGuard":null,"tryCatchPattern":"try:\n    pdf_bytes = await render_resume_pdf(url, selector)\nexcept PDFRenderError as e:\n    if str(e) == \"PDF renderer failed to initialize.\":\n        await asyncio.sleep(1)\n        pdf_bytes = await render_resume_pdf(url, selector)  # retry re-runs lazy init\n    else:\n        raise","preventionTips":["Check deploy logs for the browser-install step succeeding before serving traffic","Wrap lazy init with explicit error propagation instead of leaving _browser None","Warm up the renderer at startup with a probe render","Serialize init so concurrent first requests don't race the launch","On Windows ensure the subprocess-friendly event loop policy is set"],"tags":["pdf","playwright","initialization","lifecycle"],"backgroundTag":"renderer-not-initialized","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}