tinyscript and V8 isolates

V8 isolates power Cloudflare Workers, and they are the fastest way to run JavaScript there is. Running untrusted code in them safely takes more than an isolate, by V8's own account. Here is the difference.

Skip to the verdictCompare every engine

What V8 isolates do well

Most JavaScript in the world was written for V8, and expects all of the language at full speed.

An isolate is an instance of V8 with completely separate state; an embedder can make many and run them on parallel threads. You get the whole current language and WebAssembly, compiled by one of the best JITs there is.

Cloudflare runs many tenants' isolates in one process, and that model is proven at enormous scale. Nothing tinyscript does will match V8's peak speed on long-running hot code.

An isolate is not a boundary alone

Putting code you don't trust in an isolate feels like a sandbox, and V8 says it isn't one.

V8's security policy says embedders running untrusted code must isolate V8 inside an OS-sandboxed process. Cloudflare does exactly that, and adds cordons, seccomp, frozen timers and fast patching on top.

tinyscript has no ambient capability to take away: it only has the buffer you gave it and the messages you answer. It has no external audit yet, so treat that as design, not proof.

V8 asks for a process sandbox

Embedders executing untrusted code must always isolate V8 inside an OS-sandboxed process; a V8 isolate is not a process-level boundary.

Source:V8, SECURITY.md

A call is terminated, not paused

TerminateExecution forcefully ends the current thread of JavaScript execution with an uncatchable exception.

Source:V8 API, v8::Isolate

QuestionV8 isolatestinyscript
Language and speedAll of it, JIT-compiled62.9% of test262; an interpreter
BoundaryAn isolate inside a sandboxed processA message interface by construction
MemoryAround 3 MB each, Cloudflare said in 2018A realm's heap and about 166 KB of stacks
Bounding a callA time limit that terminatesExact fuel; the call continues
SnapshotsStart-up snapshots, trusted input onlySessions saved as their values

Which one to choose

Most readers need one answer: which engine to try first.

  • Use V8 isolates whenyou need the whole language at full speed, can run each trust level in its own sandboxed process, and a call that runs too long may simply be killed.
  • Use tinyscript whenyou need hundreds of thousands of sessions in one process, every effect under your control, and calls you can pause and continue.

Visit V8Compare every engine