{"record":{"id":"1cfb32b8b39ecefa","repo":"amruthpillai/reactive-resume","slug":"internal-server-error-1cfb32","errorCode":"INTERNAL_SERVER_ERROR","errorMessage":"Failed to generate resume PDF","messagePattern":"Failed to generate resume PDF","errorType":"exception","errorClass":"ORPCError","httpStatus":500,"severity":"error","filePath":"packages/api/src/features/resume/export.ts","lineNumber":49,"sourceCode":"\tconst filename = generateFilename(target === \"cover-letter\" ? `${resume.name} Cover Letter` : resume.name, \"pdf\");\n\n\ttry {\n\t\t// Lazy-load the PDF renderer (@reactive-resume/pdf → @react-pdf/renderer +\n\t\t// phosphor-icons-react-pdf, ~10.6k icon modules) only when a PDF is actually\n\t\t// exported, instead of at server boot. Slashes cold-start file I/O on\n\t\t// constrained/slow-disk hosts. See fork perf/lazy-load-pdf.\n\t\tconst { createResumePdfFile } = await import(\"@reactive-resume/pdf/server\");\n\t\tconst body = await createResumePdfFile({ data: getResumeExportData(data, target), filename });\n\n\t\treturn {\n\t\t\theaders: {\n\t\t\t\t\"content-disposition\": `attachment; filename=\"${filename}\"`,\n\t\t\t},\n\t\t\tbody,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\"[PDF API] Failed to render resume PDF\", { resumeId: input.id, error });\n\t\tthrow new ORPCError(\"INTERNAL_SERVER_ERROR\", { message: \"Failed to generate resume PDF\" });\n\t}\n}\n\nexport const downloadResumePdfProcedure = protectedProcedure\n\t.route({\n\t\tmethod: \"GET\",\n\t\tpath: \"/resumes/{id}/pdf\",\n\t\ttags: [\"Resumes\"],\n\t\toperationId: \"downloadResumePdf\",\n\t\tsummary: \"Download resume as PDF\",\n\t\tdescription:\n\t\t\t\"Generates a PDF for the specified resume and returns it as a forced download. Only resumes belonging to the authenticated user can be downloaded. Requires authentication.\",\n\t\tsuccessDescription: \"The generated resume PDF.\",\n\t\toutputStructure: \"detailed\",\n\t})\n\t.input(\n\t\tz.object({\n\t\t\tid: z.string().describe(\"The ID of the resume.\"),","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/api/src/features/resume/export.ts#L31-L67","documentation":"Catch-all around the lazy-loaded PDF renderer in createResumePdfDownload(). Any error from the dynamic import('@reactive-resume/pdf/server') or createResumePdfFile() is logged with the resumeId and re-thrown as INTERNAL_SERVER_ERROR. The NOT_FOUND at line 28 is thrown before the try block, so it propagates unchanged. The original error is only in server logs, not the response.","triggerScenarios":"Font registration failure, a React-PDF render error (malformed node, unreachable image URL), out-of-memory on large resumes, a broken template, or the pdf package failing to load.","commonSituations":"A resume referencing a remote image that 404s, a corrupted font file, a template bug after a package upgrade, or insufficient container memory.","solutions":["Inspect server logs for the '[PDF API] Failed to render resume PDF' line — it carries the underlying error.","Validate image URLs and font paths in the resume data before exporting.","Reproduce locally by calling createResumePdfFile({data, filename}) directly to get the raw error.","Increase container memory if rendering large or multi-page resumes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function validateResumeAssets(data) {\n  const urls = [];\n  for (const url of urls) { try { new URL(url); } catch { throw new Error(`Bad image URL: ${url}`); } }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createResumePdfDownload({ id, userId });\n} catch (e) {\n  if (e.code === 'INTERNAL_SERVER_ERROR') {\n    // surface a generic 'export failed' message; the cause is in server logs\n    console.error('PDF export failed for', id);\n  } else throw e;\n}","preventionTips":["Validate image URLs and font references in resume data before export.","Reproduce rendering failures locally with createResumePdfFile to see the raw error.","Monitor server logs for '[PDF API] Failed to render resume PDF'."],"tags":["resume","pdf-export","internal-server-error","rendering"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}