musistudio/claude-code-router · warning
[export] Failed to process exported PNG: ${formatError(error
Error message
[export] Failed to process exported PNG: ${formatError(error)} What it means
Post-processing a captured PNG (decoding, resizing, or applying the rounded-corner alpha mask) failed, so the code falls back to native-image resizing or returns the raw PNG.
Source
Thrown at packages/electron/src/main/ipc.ts:710
}
try {
const decoded = decodePngPixels(png);
let width = decoded.width;
let height = decoded.height;
let rgba = pngPixelsToRgba(decoded);
if (outputWidth && outputHeight && (outputWidth !== width || outputHeight !== height)) {
rgba = resizeRgbaBilinear(rgba, width, height, outputWidth, outputHeight);
width = outputWidth;
height = outputHeight;
}
if (radius > 0 && cssWidth > 0) {
const pixelRadius = Math.min(width / 2, height / 2, radius * width / cssWidth);
applyRoundedAlphaMask(rgba, width, height, pixelRadius);
}
return encodeRgbaPng(width, height, rgba);
} catch (error) {
console.warn(`[export] Failed to process exported PNG: ${formatError(error)}`);
const resized = resizePngWithNativeImage(png, outputWidth, outputHeight);
if (resized) {
return resized;
}
return png;
}
}
function resizePngWithNativeImage(png: Buffer, width?: number, height?: number): Buffer | undefined {
if (!width || !height) {
return undefined;
}
try {
const image = nativeImage.createFromBuffer(png);
if (image.isEmpty()) {
return undefined;
}
return image.resize({ height, width }).toPNG();View on GitHub (pinned to 99f24806c6)
Solutions
- Sanitize outputWidth/outputHeight with sanitizePngOutputDimension before calling
- Ensure the captured element has non-zero size and is visible
- Pass radius=0 to skip mask processing and test whether mask math is the cause
Example fix
// before
pngWithExportProcessing(png, { width, height, radius, cssWidth });
// after
pngWithExportProcessing(png, {
width: sanitizePngOutputDimension(width) ?? png.width,
height: sanitizePngOutputDimension(height) ?? png.height,
radius, cssWidth
}); Defensive patterns
Strategy: fallback
Validate before calling
const w = sanitizePngOutputDimension(outputWidth); const h = sanitizePngOutputDimension(outputHeight); if (!w || !h || w * h > 50_000_000) throw new RangeError('bad dims'); Type guard
const isFinitePositive = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n) && n > 0;
Try / catch
catch (error) { warn; return resizePngWithNativeImage(png, w, h) ?? png; } Prevention
- Sanitize IPC-supplied dimensions
- Ensure captured element is visible and non-zero size
When it happens
Trigger: captureElementPng/renderHtmlPng with extreme dimensions (0 or huge width/height), corrupt PNG bytes from capturePage, or a radius larger than the image producing invalid Math in the mask step.
Common situations: Capturing a hidden/zero-size element, outputWidth/outputHeight passed as 0 from unsanitized IPC input, or non-PNG bytes returned offscreen-render.
Related errors
- [export] Failed to resize exported PNG fallback: ${formatErr
- [export] Failed to include ${file}: ${formatError(error)}
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/1abc6e8f0b98fb46.
Report an issue: GitHub.