cloudflare / workerd
The JavaScript / Wasm runtime that powers Cloudflare Workers
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing cloudflare/workerd in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler view👷 , Cloudflare's JavaScript/Wasm Runtime (pronounced: "worker-dee") is a JavaScript / Wasm server runtime based on the same code that powers Cloudflare Workers. You might use it: • **As an application server**, to self-host applications designed for Cloudflare Workers. • **As a development tool**, to develop and test such code locally. • **As a programmable HTTP proxy** (forward or reverse), to efficiently intercept, modify, and route network requests. Introduction Design Principles • **Server-first:** Designed for servers, not CLIs nor GUIs. • **Standard-based:** Built-in APIs are based on web platform standards, such as . • **Nanoservices:** Split your application into components that are decoupled and independently-deployable like microservices, but with performance of a local function call. When one nanoservice calls another, the callee runs in the same thread and process. • **Homogeneous deployment:** Instead of deploying different microservices to different machines in your cluster, deploy all your nanoservices to every machine in the cluster, making load balancing much easier. • **Capability bindings:** configuration uses capabilities instead of global namespaces to connect nanoservices to each other and external resources. The result is code that is more composable -- and immune to SSRF attacks. • **Always backwards compatible:** Updating to a newer version will never break your JavaScript code. 's version number is simply a date, corresponding to the maximum "compatibility date" supported by that version. You can always configure your worker to a past date, and will emulate the API as it existed on that date. Read the blog post to learn more about these principles. WARNING: is not a hardened sandbox tries to isolate each Worker so that it can only access the resources it is configured to access. However, on its own does not contain suitable defense-in-depth against the possibility of implementation bugs. When using to run possibly-malicious code, you must run it inside an appropriate secure sandbox, such as a virtual machine. The Cloudflare Workers hosting service in particular uses many additional layers of defense-in-depth. With that said, if you discover a bug that allows malicious code to break out of , please submit it to Cloudflare's bug bounty program for a reward. Getting Started Supported Platforms In theory, should work on any POSIX system that is supported by V8 and Windows. In practice, is tested on: • Linux and macOS (x86-64 and arm64 architectures) • Windows (x86-64 architecture) On other platforms, you may have to do tinkering to make things work. Building To build , you need: • Bazel • If you use Bazelisk (recommended), it will automatically download and use the right version of Bazel for building workerd. • On Linux: • We use the clang/LLVM toolchain to build workerd and support version 19 and higher. Earlier versions of clang may still work, but are not officially supported. • Clang 19+ (e.g. package on Debian Trixie). If clang is installed as please create a symlink to it in your PATH named , or use on command lines to specify the compiler name. • libc++ 19+ (e.g. packages and ) • LLD 19+ (e.g. package ). • , , and • On macOS: • Xcode 16.3 installation (available on macOS 15 and higher). Building with just the Xcode Command Line Tools is not being tested, but should work too. • Homebrew installed package (provides Tcl 8.6) • On Windows: • Install App Installer from the Microsoft Store for the package manager and then run install-deps.bat from an administrator prompt to install bazelisk, LLVM, and other dependencies required to build workerd on Windows. • Add to the file in your user directory. • When developing at the command-line, run bazel-env.bat in your shell first to select tools and Windows SDK versions before running bazel. You may then build at the command-line with: You can pass to compile in release mode: You can also build from within Visual Studio Code using the instructions in docs/vscode.md. The compiled binary will be located at . If you run a Bazel build before you've installed some dependencies (like clang or libc++), and then you install the dependencies, you must resync locally cached toolchains, or clean Bazel's cache, otherwise you might get strange errors: If that fails, you can try: The cache will now be cleaned and you can try building again. If you have a fairly recent clang packages installed you can build a more performant release version of workerd: Configuring is configured using a config file written in Cap'n Proto text format. A simple "Hello World!" config file might look like: Where contains: Complete reference documentation is provided by the comments in workerd.capnp. There is also a library of sample config files. Running To serve your config, do: For more details about command-line usage, use . Prebuilt binaries are distributed via . Run to use these. If you're running a prebuilt binary, you'll need to make sure your system has the right dependencies installed: • On Linux: • glibc 2.35 or higher (already included on e.g. Ubuntu 22.04, Debian Bookworm) • On macOS: • macOS 13.5 or higher • The Xcode command line tools, which can be installed with • x86_64 CPU with at least SSE4.2 and CLMUL ISA extensions, or arm64 CPU with CRC extension (enabled by default under armv8.1-a). These extensions are supported by all recent x86 and arm64 CPUs. Local Worker development with You can use Wrangler (v3.0 or greater) to develop Cloudflare Workers locally, using . First, run the following command to configure Miniflare to use this build of . Then, run: Serving in production is designed to be unopinionated about how it runs. One good way to manage in production is using . Particularly useful is 's ability to open privileged sockets on 's behalf while running the service itself under an unprivileged user account. To help with this, supports inheriting sockets from the parent process using the…