Skip to main content
For OS-level memory isolation, use the worker threads adapter. This provides stronger isolation than the default VM context by running code in separate Node.js worker threads.

Basic Usage

Worker Pool Features

  • Pool management - Auto-scaling with min/max workers
  • Memory monitoring - Workers recycled when exceeding limits
  • Hard halt - Force terminate via worker.terminate()
  • Rate limiting - Message flood protection
  • Dual-layer sandbox - Worker thread + VM context isolation

Worker Pool Presets

Using Presets

Configuration Options

Memory Isolation Benefits

Worker threads provide stronger isolation than VM contexts alone:
  1. Separate V8 heap - Each worker has its own memory space
  2. Hard memory limits - OS-level enforcement via --max-old-space-size
  3. Process-like isolation - Worker crash doesn’t affect main process
  4. Clean termination - worker.terminate() guarantees cleanup

When to Use Worker Pool

Use the worker pool adapter when:
  • Running code from completely untrusted sources
  • Memory isolation is critical
  • You need hard termination guarantees
  • Processing many concurrent executions
Use the default VM adapter when:
  • Memory isolation is less critical
  • You need lower latency
  • Running trusted or semi-trusted code
  • Simpler deployment is preferred

Dual-Layer Sandbox

The worker pool provides two layers of isolation:
  1. Worker Thread - OS-level process isolation
  2. VM Context - JavaScript-level sandboxing

Monitoring Worker Health