Skip to main content
Code Execution

Code Node (& Function Node)

The Code Node runs JavaScript in a secure code sandbox, including async/await. No network, no timers, no modules.

Written By Philippe

Last updated 3 days ago

Code Node (& Function Node)

⚠️ Limitations — Works with known restrictions, see details below

Compatibility

On indie.money, the Code node runs in a secure code sandbox instead of Node.js:

FeatureStatus
JavaScriptSupported
async/await, Promises, Promise.allSupported
$input, $json, $binary, $node, $workflow, $execution, $vars, $runIndexSupported
Writes through $json and $input.item see each other, as in n8nSupported
$now, $today, DateTime, Duration, Interval (Luxon, full build)Supported — dates use the workflow's Timezone setting, as in n8n. With no setting, UTC
DateTime.fromFormat(), DateTime.fromRFC2822()Supported
$('NodeName'), $node['Name'], $items()Supported — when $('NodeName').item, .pairedItem() or .itemMatching() cannot trace the item back, the node stops with n8n's error, as in n8n
$jmespath(object, expression)Supported
$parameter, $rawParameter, $thisItem, $nodeVersion, $nodeIdSupported
Intl.NumberFormat, Intl.DateTimeFormatSupported
toLocaleString(), toLocaleDateString(), toLocaleTimeString()Supported — full locale data
Buffer (from, alloc, concat, compare, byteLength, isBuffer, toString, slice, subarray, indexOf, includes, equals, fill)Supported — utf8, base64, base64url, hex, latin1. The numeric read*/write* methods are not included
TextEncoder, TextDecoderSupported — UTF-8 and latin1
crypto.randomUUID(), crypto.getRandomValues()Supported
this.helpers binary methods (getBinaryDataBuffer, prepareBinaryData, setBinaryDataBuffer, assertBinaryData, binaryToString)Supported — prepareBinaryData takes the MIME type you pass, or detects it from the file name; with neither it uses text/plain
PythonNot supported — JavaScript only
setTimeout / setIntervalNot supported — refused at upload. No timers; use the Wait node to delay a run
fetch / HTTPNot supported — refused at upload; use HTTP Request node instead
Other this.helpers methodsNot supported — for network calls (httpRequest, request) use the HTTP Request node
require / importNot supported — refused at upload; no external modules
URL, URLSearchParams, structuredCloneNot supported — refused at upload. Build query strings with string methods, and copy objects with JSON.parse(JSON.stringify(value))
$secretsNot supported — refused at upload. External secret providers are unavailable. Use $vars, or a credential on an HTTP Request node
$execution.customDataNot supported — refused at upload. Executions cannot be annotated. Return the value as part of your items instead
Intl.RelativeTimeFormatNot supported — refused at upload. Intl.DateTimeFormat, Intl.NumberFormat and Intl.ListFormat are. For relative times use DateTime.toRelative()
Buffer.read* / Buffer.write*Not supported — the numeric accessors are unavailable. Index the bytes directly or use a DataView
crypto.subtle.digestPartial — SHA-256 and SHA-1 only. Another algorithm raises an error naming the supported ones
crypto.subtle signingNot supported — sign, verify, encrypt, decrypt, importKey and key derivation are refused at upload. They need key material, which is never exposed to a Code node. Let the API you call do the signing
console.logNo output — it does not fail, it is silently discarded. Use return to see data
process.envNot supported — refused at upload; use $vars for values you set on the workflow
File systemNot supported — no fs access
$getWorkflowStaticDataNot supported — refused at upload. Nothing written to it ever survived. Use $('NodeName') to pass data between nodes, or an HTTP Request node for an external store
$envNot supported — n8n denies it by default; we refuse the workflow at upload. Use $vars
$fromAI, $toolNot supported — refused at upload. It is filled in by an AI Agent calling a tool, so it has no value in a Code node; read the value from $json
$evaluateExpressionNot supported — refused at upload. Expressions must be resolved before the Code node; reference the value with $json or $('NodeName')
$selfPartial — Returns empty object. Not populated until after Code node executes

Limits:

  • Secure code sandbox CPU limit (5 seconds to 5 minutes) — Heavy computation has its own compute limit, from a 5-second floor up to 5 minutes depending on the workflow's price per run. The limit is for the whole run: all Code steps in a run share it. Waiting on APIs, LLMs, or webhooks does not count against it. This limit is time spent running code inside the secure code sandbox; since code there has no network or timers to wait on, awaiting cannot idle against the limit. Network waits in HTTP Request, LLM, and database nodes use the workflow execution limits below instead.
  • "Step … reached this run's … compute limit" — the run used up its compute time. The message names the step and the run price that gives more time. Raise the run price, or move heavy work out of the Code node. At the highest tier, split the work across more runs.
  • 5-minute wall-clock timeout — total elapsed time including I/O wait. Awaiting does not consume the CPU budget by idling — with no network or timers in the sandbox, there is nothing to wait on.
  • Memory 16 MB — Code that uses more stops on that node with "This step ran out of memory." Keep less data in memory at one time.
  • Recursion depth about 1,100 calls — Deeper recursion stops with stack overflow.
  • Results keep plain data — undefined, NaN, Infinity and empty array slots come back as null, and a Set or Map comes back as {}. Return an array or an object instead.

Status

This integration works on indie.money with known limitations. See the details above for specifics.