Tech Debts β Kroki-rs v0.0.2ΒΆ
Identified during pre-release code review. Ordered by impact Γ effort.
π΄ CriticalΒΆ
TD-01:
convert()andconvert_to_file()are 95% duplicated (cli/mod.rs)TD-02: Font aggregation copy-pasted 4Γ (
main.rs,cli,handlers)TD-03: WebP format-routing copy-pasted 3Γ (
cli,handlers)TD-13: Timeout errors lose all context β no tool name, input size, or partial stderr (
diagrams/mod.rs)TD-14: Spawn errors are generic β donβt identify which binary failed (
diagrams/mod.rs)TD-15: Provider errors are opaque strings, not structured (
all providers)TD-19: No input size limits anywhere β unbounded memory risk (
handlers,cli)
π MajorΒΆ
TD-04: Capabilities re-discovered on every HTTP request (
handlers.rs,cli)TD-05: Server uses
println!instead oftracing(server/mod.rs)TD-06: Server discovers capabilities but discards them (
server/mod.rs)TD-07: Configuration priority pattern not established (
all providers) β deferred to v0.0.3TD-16: Server leaks internal errors to clients (
handlers.rs)TD-17: No partial stderr capture on timeout (
diagrams/mod.rs)TD-20: No output size validation (
handlers,cli)TD-21: No format whitelist β arbitrary strings reach providers (
handlers.rs)
[TD-30] Centralize Temp File ManagementΒΆ
Description: Various providers (bpmn.rs, vega.rs) generate and manage their own temporary files and directories.
Impact: Duplicate logic for cleanup and error handling. Potential for orphaned files if a process forcefully terminates.
Remediation: Create a unified TempWorkspace utility that handles lifecycle management, guaranteeing cleanups via Drop traits and reducing boiler plate in generation routes.
[x] [TD-31] Playwright Instance Pooling & Universal Browser RendererΒΆ
Description: Subprocess execution of mermaid-cli or bpmn-to-image currently spins up isolated Puppeteer/Chromium instances for every conversion request. This carries an immense overhead that negatively scales memory footprint and latency.
Impact: Launching headless Chromium is notoriously expensive. Doing it dynamically per HTTP request prevents high-throughput diagram rendering and severely heightens the risk of Out-of-Memory (OOM) scenarios or memory leaks on the server.
Remediation:
Migration to Playwright: Standardize all browser-reliant generators (Mermaid, BPMN, potentially Excalidraw/Wavedrom) to use a unified Playwright engine instead of outdated puppeteer wrappers.
Instance Pooling: Implement an active pool of pre-warmed Playwright
BrowserContextobjects.TTL Enforcement: Enforce a strict Time-To-Live (TTL) or request-limit per browser instance before it is gracefully recycled, eradicating zombie memory leaks.
Abstracted Evaluation: Instead of calling CLI binaries, Kroki-rs should natively orchestrate the unified browser pool and execute
page.evaluate(...)for the respective JS libraries, maximizing performance and eliminating unnecessary disk I/O.
π‘ ModerateΒΆ
TD-08:
WebpQualityaccepted but ignored (image_converter.rs) β Lossy falls back to lossless with warning; needswebpcrate for true lossyTD-09: Cache dir resolution duplicated 3Γ (
cli,font_manager)TD-10:
cmd.rshardcodes-Tsvgignoring format paramTD-11:
validate()is no-op on every providerTD-12: Verbose per-tool debug logging in
capabilities.rsTD-18: VegaLite pipeline errors donβt identify which stage failed (
vega.rs)TD-22: Unknown type (400) conflated with tool-not-installed (503) (
handlers.rs)TD-23:
decode()hides UTF-8 errors behind generic message (utils/mod.rs)TD-24:
excalidraw.rsignores format parameterTD-25:
bpmn.rs,wavedrom.rs,ditaa.rsuse blocking I/O in asyncTD-27: Batch exits 0 even with partial failures (
cli/mod.rs)
π΅ MinorΒΆ
TD-28: Leftover TODO/exploratory comments (multiple files)
TD-29:
test_decode_debuguses println, never asserts (utils/mod.rs)TD-30:
ditaa.rsformat validation has dead code branch