{"record":{"id":"3e665e43605fda1d","repo":"windmill-labs/windmill","slug":"the-expression-evaluation-exceeded-the-memory-limi","errorCode":null,"errorMessage":"The expression evaluation exceeded the memory limit of {} MB. {}","messagePattern":"The expression evaluation exceeded the memory limit of (.+?) MB\\. (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-jseval/src/lib.rs","lineNumber":413,"sourceCode":"                .get::<_, Option<String>>(\"name\")\n                .ok()\n                .flatten()\n                .as_deref()\n                == Some(\"InternalError\")\n                && e.message().as_deref() == Some(\"out of memory\")\n        }\n        rquickjs::CaughtError::Value(v) => v.is_null() || v.is_undefined(),\n        rquickjs::CaughtError::Error(_) => false,\n    };\n    if is_oom {\n        let remediation = match env_override {\n            Some(var) => format!(\n                \"Reduce the amount of data handled in the expression, or raise the \\\n                 cap via the {var} environment variable.\"\n            ),\n            None => \"Reduce the amount of data handled in the expression.\".to_string(),\n        };\n        anyhow::anyhow!(\n            \"The expression evaluation exceeded the memory limit of {} MB. {}\",\n            memory_limit / (1024 * 1024),\n            remediation\n        )\n    } else {\n        anyhow::anyhow!(\"QuickJS evaluation error: {}\", err)\n    }\n}\n\n#[cfg(feature = \"quickjs\")]\nasync fn eval_quickjs_inner(\n    expr: &str,\n    transform_context: HashMap<String, Arc<Box<RawValue>>>,\n    flow_input: Option<mappable_rc::Marc<HashMap<String, Box<RawValue>>>>,\n    flow_env: Option<HashMap<String, Box<RawValue>>>,\n    authed_client: Option<AuthedClient>,\n    by_id: Option<IdContext>,\n    extra_ctx: Option<Vec<(String, String)>>,","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-jseval/src/lib.rs#L395-L431","documentation":"A QuickJS expression evaluation aborted because it hit the configured memory limit. The error is detected from the QuickJS error and mapped to this message, which includes the limit in MB plus remediation advice naming the environment variable that can raise the cap.","triggerScenarios":"An expression that materializes huge intermediate data — e.g. JSON.stringify on a multi-MB step result, .concat of giant strings, or spreading a very large array — inside a flow step-input transform with a memory cap set.","commonSituations":"Transforming large API responses directly in an input transform; accidental O(n) copies in a loop; running in environments (especially cloud) with a lowered default memory cap.","solutions":["Reduce the data handled in the expression — pass smaller inputs or filter upstream","Raise the memory cap via the corresponding memory-limit environment variable","Move heavy data processing into a dedicated script step with normal worker memory"],"exampleFix":"// before\nJSON.stringify(results.hugePayload)  // exceeds memory limit\n// after\nJSON.stringify({ ids: results.hugePayload.map(x => x.id) })","handlingStrategy":"validation","validationCode":"const approxBytes = JSON.stringify(input).length;\nif (approxBytes > 5_000_000) throw new Error('input too large for expression eval');","typeGuard":null,"tryCatchPattern":"try {\n  return await evalExpression(expr, inputs);\n} catch (e) {\n  if (String(e).includes('exceeded the memory limit')) {\n    // reduce payload or raise the memory cap env var and retry once\n  }\n  throw e;\n}","preventionTips":["Pass only the fields you need into transforms","Avoid JSON.stringify on multi-MB payloads inside expressions","Raise the memory-limit env var when processing large data is intentional"],"tags":["javascript","memory","flows"],"backgroundTag":"out-of-memory-limit","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}