d2lang/d2 · critical
Failed to decompress SourceCodePro-Regular: %v
Error message
Failed to decompress SourceCodePro-Regular: %v
What it means
init()-time panic in the wasm d2fonts package when the embedded brotli-compressed SourceCodePro Regular font fails to decompress. Like the other embedded fonts, failure here aborts module initialization before any rendering can occur.
Source
Thrown at d2renderers/d2fonts/d2fonts_embed_wasm.go:80
} else {
FontEncodings.Set(Font{Family: SourceSansPro, Style: FONT_STYLE_BOLD}, str)
}
if str, err := compression.DecompressBrotli(sourceSansProSemiboldBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceSansPro-Semibold: %v", err))
} else {
FontEncodings.Set(Font{Family: SourceSansPro, Style: FONT_STYLE_SEMIBOLD}, str)
}
if str, err := compression.DecompressBrotli(sourceSansProItalicBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceSansPro-Italic: %v", err))
} else {
FontEncodings.Set(Font{Family: SourceSansPro, Style: FONT_STYLE_ITALIC}, str)
}
// Decompress and register SourceCodePro fonts
if str, err := compression.DecompressBrotli(sourceCodeProRegularBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceCodePro-Regular: %v", err))
} else {
FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_REGULAR}, str)
}
if str, err := compression.DecompressBrotli(sourceCodeProBoldBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceCodePro-Bold: %v", err))
} else {
FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_BOLD}, str)
}
if str, err := compression.DecompressBrotli(sourceCodeProSemiboldBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceCodePro-Semibold: %v", err))
} else {
FontEncodings.Set(Font{Family: SourceCodePro, Style: FONT_STYLE_SEMIBOLD}, str)
}
if str, err := compression.DecompressBrotli(sourceCodeProItalicBr); err != nil {
panic(fmt.Sprintf("Failed to decompress SourceCodePro-Italic: %v", err))View on GitHub (pinned to 0d69dca6f5)
Solutions
- Verify sourceCodeProRegularBr decompresses with a standalone tool
- Regenerate the .br asset using the project's embed script
- Rebuild wasm from a clean checkout of d2
- Align brotli tool versions with the project's documented toolchain
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := compression.DecompressBrotli(sourceCodeProRegularBr); err != nil {
return fmt.Errorf("broken embedded SourceCodePro-Regular asset: %w", err)
} Prevention
- Regenerate all font .br assets together
- Validate assets in CI before publishing
- Keep brotli toolchain versions consistent
- Rebuild from clean checkouts
When it happens
Trigger: Package init of the wasm build when compression.DecompressBrotli(sourceCodeProRegularBr) returns an error due to corrupt/empty/mismatched embedded asset.
Common situations: Faulty asset generation in the wasm build pipeline; truncated embedded files; version mismatch between brotli compressor and the Go brotli decompressor.
Related errors
- Failed to decompress SourceSansPro-Regular: %v
- Failed to decompress SourceSansPro-Bold: %v
- Failed to decompress SourceSansPro-Semibold: %v
- Failed to decompress SourceSansPro-Italic: %v
- Failed to decompress SourceCodePro-Bold: %v
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/0a06c46d959dd15d.
Report an issue: GitHub.