debug resvg cli
Some checks failed
Build & Deploy / build-and-deploy (push) Failing after 18s

This commit is contained in:
svemagie
2026-03-31 21:03:04 +02:00
parent 79bf98387a
commit 9ce9f4aa09

View File

@@ -519,6 +519,25 @@ export async function generateOgImages(contentDir, cacheDir, siteName, batchSize
if (generated % SAVE_INTERVAL === 0) {
writeFileSync(manifestPath, JSON.stringify(newManifest, null, 2));
}
try {
const result = spawnSync('resvg', ["-w", String(WIDTH), "-b", COLORS.bg, "-o", outPath, "-"], { input: svg, encoding: null });
if (result.error) {
console.error(`[og] resvg CLI error for ${outPath}:`, result.error);
throw result.error;
}
if (result.status !== 0) {
console.error(`[og] resvg CLI failed for ${outPath}:`, result.stderr && result.stderr.toString());
throw new Error(result.stderr && result.stderr.toString());
}
if (!result.stdout || result.stdout.length === 0) {
console.error(`[og] resvg CLI produced no output for ${outPath}`);
throw new Error('resvg CLI produced no output');
}
console.log(`[og] Wrote: ${outPath}`);
} catch (e) {
console.error(`[og] Exception for ${outPath}:`, e);
require('fs').writeFileSync(outPath.replace(/\.png$/, '.svg'), svg);
}
// Force GC to reclaim Satori/Resvg WASM native memory.
if (hasGC && generated % GC_INTERVAL === 0) {