Curated summary
Workers RPC now works across Python and JavaScript
Workers RPC, originally based on Cap’n Proto RPC, is expanding from JavaScript-only communication to seamless JavaScript–Python interoperability through Cap’n Web. Workers can call methods, pass objects and functions, propagate exceptions, and use native language types without schemas, dependencies, or significant performance overhead. The result is a multi-language system that can be used much like a local library.
Cross-Language RPC in Workers
- JavaScript Workers can call Python Worker methods, and Python Workers can call TypeScript methods.
- Objects, functions, streams, and live remote objects can be passed between Workers.
- A Service binding is the only required configuration.
- RPC calls return promises in JavaScript/TypeScript and futures in Python.
- Exceptions propagate back to the call site.
- Most calls run in the same thread, providing near-zero overhead compared with local execution.
- The implementation is open source through
workerdandworkers-runtime-sdk.
Automatic Type Conversion
- RPC supports Structured Cloneable values as parameters and return values.
- Common types are converted into native equivalents, such as JavaScript
Dateto Pythondatetime. - JavaScript objects can correspond to Python dictionaries, while Python keyword arguments can represent JavaScript options objects.
- Functions can cross the language boundary; invoking a transferred function creates a reverse RPC call to its original Worker.
Pyodide’s Role
- Python Workers use Pyodide, a WebAssembly-compiled CPython runtime.
- Pyodide’s Foreign Function Interface translates common values automatically:
- Python
intandfloat→ JavaScriptNumber - Python
bool→ JavaScriptBoolean - Python
dict→ JavaScriptObject - Python
list→ JavaScriptArray
- Python
- Types that cannot be directly converted, such as custom classes and functions, are represented by proxies that forward property access and method calls.
Handling Worker-Specific Objects
- Standard Web API objects such as
Request,Response,Blob, andFiledo not have direct Python equivalents. - Pyodide initially exposes these values as JavaScript proxy objects.
- Although proxies remain functional, they expose JavaScript implementation details to Python developers and make the API less natural.
- The project therefore requires an additional conversion layer to provide Python-friendly representations of Cloudflare Workers objects.
Practical Implication
Cross-language Workers RPC lets teams combine Python and JavaScript services without manually designing APIs or serialization formats. Developers can use each language’s native calling conventions while the runtime handles translation, proxies, and communication behind the scenes.
Related reading
Continue with another curated summary.
Sandboxing AI agents, 100x faster
Read originalHow AI is reshaping developer choice (and Octoverse data proves it)
Read originalHow to build a plugin system on the web and also sleep well at night | Figma Blog
Read originalIntroducing Kitesurf: The agent-first browser that runs in V8 isolates on Cloudflare Workers
Read original