Skip to content

Investigate QuickJS as an asyncio-friendly JS sandbox#107

Merged
simonw merged 2 commits intomainfrom
claude/quickjs-async-sandbox-4uC5b
Apr 12, 2026
Merged

Investigate QuickJS as an asyncio-friendly JS sandbox#107
simonw merged 2 commits intomainfrom
claude/quickjs-async-sandbox-4uC5b

Conversation

@simonw
Copy link
Copy Markdown
Owner

@simonw simonw commented Apr 12, 2026

Builds AsyncQuickJSSandbox with memory + wall-clock limits, exposing
selected Python functions (including async httpx-backed fetch) to
sandboxed JavaScript. Documents three important gotchas: time-limit is
incompatible with Python callbacks, it cannot be used to interrupt from
another thread, and raising Python exceptions in callbacks corrupts the
context.

https://claude.ai/code/session_01NcLEygpripiZZYRLPAP4UY

claude added 2 commits April 12, 2026 21:29
Builds AsyncQuickJSSandbox with memory + wall-clock limits, exposing
selected Python functions (including async httpx-backed fetch) to
sandboxed JavaScript. Documents three important gotchas: time-limit is
incompatible with Python callbacks, it cannot be used to interrupt from
another thread, and raising Python exceptions in callbacks corrupts the
context.

https://claude.ai/code/session_01NcLEygpripiZZYRLPAP4UY
test_kill_thread.py confirms pure-JS infinite loops can't be killed
in-process: ctypes exception injection only fires on Python bytecode,
and QuickJS runs entirely in C. sandbox_process.py forks a child,
forwards fetch/sleep RPCs to the parent's asyncio loop, and SIGKILLs
the child on timeout. Costs ~15ms of fork overhead per run but
guarantees termination of adversarial JS.

https://claude.ai/code/session_01NcLEygpripiZZYRLPAP4UY
@simonw simonw merged commit 4d4f63f into main Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants