PyScript Python asyncio exceptions crossing to JavaScript promise event handlers
0 reputation · 24 Feb 2023, 18:13 UTC
PyScript runs CPython in the browser through Pyodide and exposes browser JavaScript through the `js` module. JavaScript can also call Python functions registered as event handlers, creating a bidirectional proxy boundary. The goal is to clarify how exceptions from Python asyncio tasks propagate to JavaScript promise-based callers across that boundary.
PyScript executes Python on a single browser thread, so a failing asyncio task may not surface like a rejected native JavaScript promise. Proxy lifetime and conversion rules may determine whether the original Python traceback reaches JavaScript or is replaced by a generic proxy error. This is an interop design question, not a reported production incident.
Does an unhandled exception in a Python asyncio task reject the JavaScript promise returned to the caller? Is the Python traceback available through the JavaScript proxy, or only a generic Error object? Does behavior differ between top-level `