d2lang/d2 · error
failed to fully %scompile (rendering partial svg): %w
Error message
failed to fully %scompile (rendering partial svg): %w
What it means
During watch recompilation, compile() may fail after it has already produced a partial SVG. Watch wraps the original error with the prefix "failed to fully <re>compile (rendering partial svg)" so the user knows an incomplete (partial) diagram was rendered from a full or recompile.
Source
Thrown at d2cli/watch.go:451
Err: broadcastErr.Error(),
})
continue
}
w.pw = newPW
}
fs := trackedFS{}
w.boardpathMu.Lock()
var boardPath []string
if w.boardPath != "" {
boardPath = strings.Split(w.boardPath, string(os.PathSeparator))
}
svg, _, err := compile(ctx, w.ms, w.plugins, &fs, w.layout, w.renderOpts, w.fontFamily, w.monoFontFamily, w.animateInterval, w.inputPath, w.outputPath, boardPath, false, w.bundle, w.forceAppendix, w.pw.Browser, w.outputFormat, w.asciiMode)
w.boardpathMu.Unlock()
errs := ""
if err != nil {
if len(svg) > 0 {
err = fmt.Errorf("failed to fully %scompile (rendering partial svg): %w", recompiledPrefix, err)
} else {
err = fmt.Errorf("failed to %scompile: %w", recompiledPrefix, err)
}
errs = err.Error()
w.ms.Log.Error.Print(errs)
}
err = w.replaceWatchList(ctx, fs.opened)
if err != nil {
return err
}
w.broadcast(&compileResult{
SVG: string(svg),
Scale: w.renderOpts.Scale,
Err: errs,
})
if firstCompile {View on GitHub (pinned to 0d69dca6f5)
Solutions
- Fix the underlying wrapped error shown after the %w portion (it names the actual failing element/key)
- Check the referenced shape/key in your .d2 source for invalid values
- Save a valid file so watch performs a clean recompile
Example fix
// before x.style.fill-pattern: stripes # invalid // after x.style.fill-pattern: dots
Defensive patterns
Strategy: validation
Validate before calling
// run a one-shot compile to validate before watching: // d2 file.d2 /tmp/out.svg && d2 file.d2 --watch
Try / catch
if strings.Contains(errStr, "failed to fully") {
// partial svg rendered: fix the wrapped cause, watch will re-render fully
} Prevention
- Fix the wrapped underlying error first — it names the failing element
- Validate .d2 files with a non-watch run before long watch sessions
- Keep multi-board files syntactically consistent while editing
When it happens
Trigger: compile() returns both a non-empty svg and an error — e.g. one board of a multi-board diagram fails while others rendered, or a downstream render step (export/animation) fails after SVG generation.
Common situations: Syntax or semantic errors in part of a .d2 file being edited in watch mode, invalid style values on some shapes, or an export step failing after the SVG was built.
Related errors
- failed to %scompile: %w
- response.error.message
- failed to fully compile (partial render written) %s: %w
- failed to compile %s: %w
- issue encountered with PNG exporter: %w
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/9c2f7b9c9679347f.
Report an issue: GitHub.