QuickJS Executor Reference

Technical reference for the QuickJS JavaScript sandbox used to run Code Nodes on Cloudflare Workers.

Written By pvdyck

Last updated About 1 hour ago

QuickJS Executor Reference

indie.money uses QuickJS β€” a lightweight, embeddable JavaScript engine β€” to run Code Nodes inside Cloudflare Workers. This page explains why and what constraints it imposes.

Why QuickJS?

Cloudflare Workers do not support Node.js APIs or most browser APIs. QuickJS is a pure JavaScript engine that can be compiled to WebAssembly (WASM) and run inside a Worker. It provides a safe, isolated sandbox for custom code.

Constraint Table

FeatureAvailable?Note async/await❌ NoCode must be synchronous fetch / XMLHttpRequest❌ NoNo network access from Code Node require / import❌ NoNo module system console.log❌ NoLogs discarded; use return values setTimeout / setInterval❌ NoNo timers File system (fs)❌ NoNo file access Math, Date, JSONβœ… YesFull standard library Array, Object, String, RegExpβœ… YesFull standard library Promises⚠️ LimitedCan create Promises but cannot await them Generatorsβœ… YesSynchronous generators work ES2020 syntaxβœ… YesArrow functions, destructuring, spread, etc.

CPU Time Limit

Each Code Node execution has a 2-minute CPU time limit. This counts actual CPU computation, not wall-clock time. Infinite loops will be terminated.

Performance

QuickJS is slower than V8 (Chrome's engine). Complex string manipulation or large array operations may be noticeably slower than you'd expect. Keep Code Node logic lean β€” offload complex processing to upstream HTTP requests where possible.

Available n8n Variables

  • $input β€” input items (.all(), .first(), .last(), .item(), .context, .params) - $json β€” shortcut to first item's JSON - $('NodeName') β€” access other nodes (.first(), .last(), .all(), .item(), .json, .context, .params) - $node['Name'] β€” proxy-based node accessor (.json, .binary, .context, .parameter, .runIndex) - $item(n) β€” access item by index - $items() β€” all items as INodeExecutionData[] - $prevNode β€” previous node info (name, outputIndex, runIndex) - $workflow β€” workflow metadata (id, name, active) - $env β€” environment variables - $vars β€” workflow variables - $execution β€” execution metadata - $mode β€” execution mode - $now, $today, $yesterday β€” Luxon-like dates (.toISO(), .toFormat(), .plus(), .minus()) - DateTime β€” date factory (.now(), .fromISO(), .fromJSDate()) - $nodeVersion, $nodeId β€” node metadata - $itemIndex, $runIndex β€” current indices - $getNodeParameter β€” access node parameters

Related