How Cloudflare Uses ASTs to Turn Workflows Code into Visual Diagrams
- Cloudflare Workflows
- JavaScript Oxidation Compiler (OXC)
- oxc-parser
AI Summary
Cloudflare explains how they automatically generate visual execution diagrams for user-written workflows by parsing code using Abstract Syntax Trees (ASTs). Because Cloudflare Workflows use a dynamic execution model based on code rather than static configs, rendering accurate graphs is complex. The engineering team parses minified JavaScript from various bundlers using oxc-parser running in a Rust-based Cloudflare Worker via WebAssembly. They track promises, loops, branches, and function relationships using custom starts and resolves fields to map out parallel and sequential steps in the final UI dashboard.
Key Takeaways
- Details the use of oxc-parser and Rust via WebAssembly inside a Cloudflare Worker.
- Explains how dynamic execution and minified code from various bundlers complicate graph generation.
- Discusses tracking starts and resolves indices for promises to align parallel steps in the diagram UI.
Why it matters
This article provides valuable architectural insights into static code analysis, using WebAssembly for high-performance parsing in edge workers, and handling dynamic execution models like Promises and async control flow for visualization purposes.
Conversation0
What would you add from your experience?
Checking your session…
Every good conversation starts with one perspective.