siyuan-note/siyuan · error

window.siyuan.languages.exportFileSaveFailed

Error message

window.siyuan.languages.exportFileSaveFailed

What it means

outputImage renders the editor (or a block) to a PNG blob; if renderImageBlob returns null/undefined the export cannot proceed and this error is thrown with the localized 'export file save failed' message, which the surrounding catch surfaces to the user.

Solutions

  1. Retry the export after ensuring the block is visible and the layout has finished
  2. Reduce the exported region (smaller block/document) to avoid canvas size/memory limits
  3. Check the dev console for renderer (canvas/html2canvas) errors preceding the null blob
  4. Verify the browser is not in a headless/limited environment where rendering APIs are unavailable

Example fix

// before
const blob = await renderImageBlob();
// after
const blob = await renderImageBlob();
if (!blob) { showMessage(window.siyuan.languages.exportFileSaveFailed); return; }
Defensive patterns

Strategy: validation

Validate before calling

if (!element || element.offsetWidth === 0 || element.offsetHeight === 0) return null; // skip export

Type guard

const hasRenderableBlob = (b: Blob | null | undefined): b is Blob => b instanceof Blob && b.size > 0;

Try / catch

try { await outputImage(...); } catch (e) { hideMessage(msgId); showMessage(window.siyuan.languages.exportFileSaveFailed); }

Prevention

When it happens

Trigger: Calling exportImage/refreshPreview when renderImageBlob() yields null — typically because the target element has zero size, is hidden/detached, html2canvas-style rendering failed, or fonts/images inside the block failed to load.

Common situations: Exporting an empty or invisible block; exporting before layout completes; browser rendering limits (canvas too large for very tall documents, memory pressure); headless environments where rendering silently fails.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/86b4330ca6eabcf8. Report an issue: GitHub.

Appendix: source

Thrown at app/src/protyle/export/util.ts:181

        const oldHeight = containerElement.style.height;
        const oldMaxHeight = containerElement.style.maxHeight;
        const oldWidth = containerElement.style.width;
        // 导出时让内容完整展开,避免移动端对话框的最大高度限制截断长图。
        containerElement.style.height = "";
        containerElement.style.maxHeight = "none";
        /// #if MOBILE
        containerElement.style.width = "100vw";
        /// #endif
        const contentElement = exportDialog.element.querySelector(".b3-dialog__content") as HTMLElement;
        const oldOverflow = contentElement.style.overflow;
        contentElement.style.overflow = "hidden";
        if (!copyOnly) {
            setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]);
        }
        try {
            const blob = await renderImageBlob();
            if (!blob) {
                throw new Error(window.siyuan.languages.exportFileSaveFailed);
            }
            if (type === "copy") {
                let copied: boolean;
                if (isInAndroid()) {
                    const response = await uploadImageBlob(blob);
                    copied = response.code === 0;
                    if (copied) {
                        copyPNGByLink(response.data.file);
                    }
                } else {
                    copied = await writePNGBlob(blob);
                }
                hideMessage(msgId);
                if (!copied) {
                    return;
                }
                showMessage(window.siyuan.languages.copied);
            } else {

View on GitHub (pinned to 9f775e8a12)