Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Bytecode Alliance 8 min read Deep dive mediumAdept

How Wasm components enable pluggable tooling through interposition

The WASI 0.3 `wasi:http` middleware world (import handler, export handler) shows how Wasm component composition enables in-process service chaining and, more generally, interposition: inserting a component between any caller and callee without modifying either. Interposition addresses three limits of language-level middleware: per-language fragmentation, the assumption of a fixed HTTP request/response interface, and opaque binaries that cannot be re-wired. Because component interfaces expose full type information, a tool can adapt generic middleware such as logging, tracing, fuzzers or record/replay to arbitrary interfaces. The `splicer` research tool discovers a component's composition graph and interposes components driven by a YAML config. It currently supports passthrough and read-only adapters, with read/write adapters planned.

Assumes: WebAssembly Component ModelWIT interfacesHTTP middleware pattern

Related posts

  • WASI 0.3 Launched

    Bytecode Alliance mediumAdept

    WASI 0.3.0 is ratified and rebases WASI onto the Component Model's native async primitives. The canonical ABI gains `stream<T>`, `future<T>` and `async func`, which replace `wasi:io` pollables and streams. Scheduling moves to a single host-managed, completion-based event loop modeled on io_uring/IOCP, so async components can finally be composed with each other. Streams now return a separate error future, and `wasi:http` is reorganized into `service` and `middleware` worlds that allow in-process service chaining. Wasmtime 46 will enable WASI 0.3 by default, jco already supports it, and Rust and Go bindings illustrate idiomatic stackless and stackful async.

  • Why is WebAssembly a second-class language on the web?

    Mozilla Hacks mediumAdept

    WebAssembly remains second-class on the web because it can only load code and reach Web APIs through JavaScript. That forces arcane instantiation boilerplate, language-specific glue code from tools like wasm-bindgen and embind, JS-centric documentation, and real runtime overhead. A 2020 TodoMVC experiment with the Dodrio Rust framework found that removing JS glue cut DOM-update time by 45%. The esm-integration proposal, being implemented in Firefox, simplifies loading, and the WebAssembly Component Model with WIT interfaces is proposed as a standardized artifact that could let Wasm call Web APIs directly with no JavaScript in between.

  • Extensible Language Support in Zed - Part 1

    Zed mediumAdept

    Zed loads third-party Tree-sitter grammars as WebAssembly modules using a hybrid design. Native code consumes the parser's static parse tables after they are copied out of wasm linear memory, while only the lexing functions, including hand-written external scanners, run inside Wasmtime. This avoids depending on the user's C compiler and keeps buggy scanners from crashing the editor. It also avoids copying large syntax trees out of wasm memory on every keystroke. A new `WasmStore` API lets wasm-loaded languages behave identically to native ones, and a bundled mini-libc with a bump allocator that is reset each parse makes scanner memory leaks impossible.

  • Introducing the WebAssembly JavaScript Promise Integration API

    V8 mediumAdept

    JSPI lets WebAssembly code written against synchronous APIs call asynchronous Web APIs. It intercepts Promises returned from wrapped JavaScript imports, suspends the Wasm computation, and resumes it from the browser's event loop when the Promise resolves. Wrapped exports return a Promise instead of a direct value. JSPI changes neither JavaScript nor Wasm, and suspend/resume costs are roughly constant: a deliberately bad Promise-based Fibonacci benchmark puts each JSPI'd call at about 1μs. The API is at phase 4 and ships in Chrome 137 and Firefox 139. Emscripten examples show `-s JSPI` with `EM_ASYNC_JS`, plus a trampoline pattern that lazily fetches and instantiates a Wasm module on first call.

  • Life of a Zed Extension: Rust, WIT, Wasm

    Zed mediumAdept

    Zed extensions are written in Rust but never compiled on the user's machine. A CI step in the zed-industries/extensions repository runs a small extensions CLI that compiles each extension's Rust code to a Wasm component targeting wasm32-wasip1 and its Tree-sitter grammars to Wasm. It packages them with Tree-sitter query files into an archive plus a manifest.json, uploads both to S3, and zed.dev mirrors the manifests into a database for the in-editor extension list. The extension API is a hand-written Rust trait layered over types that wit_bindgen generates at compile time from WIT definitions, so the WebAssembly Component Model can pass strings, records and resources like Worktree between the Wasm module and the Zed host.

The quest for software engineering knowledge.

Look:
Layout: