From de9b0896438d5e708c8efb7b045802324bfb0528 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 29 Jan 2026 09:17:10 +0000 Subject: [PATCH] fix: add 32MB memory limit to QuickJS runtime for flow expressions QuickJS was missing an explicit memory limit, unlike deno_core which has a 128MB heap limit. This adds a 32MB limit appropriate for lightweight flow expression evaluation. Co-Authored-By: Claude Opus 4.5 --- backend/windmill-worker/src/js_eval_quickjs.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/windmill-worker/src/js_eval_quickjs.rs b/backend/windmill-worker/src/js_eval_quickjs.rs index 2b7e3b7a5e..2402bcc82f 100644 --- a/backend/windmill-worker/src/js_eval_quickjs.rs +++ b/backend/windmill-worker/src/js_eval_quickjs.rs @@ -145,6 +145,11 @@ pub async fn eval_timeout_quickjs( })?? } +/// Memory limit for QuickJS runtime (32MB). +/// This is much smaller than deno_core's 128MB limit since flow expressions +/// should be lightweight transformations, not memory-intensive operations. +const QUICKJS_MEMORY_LIMIT: usize = 32 * 1024 * 1024; + async fn eval_quickjs_inner( expr: &str, transform_context: HashMap>>, @@ -156,6 +161,7 @@ async fn eval_quickjs_inner( context_keys: Vec, ) -> anyhow::Result> { let runtime = AsyncRuntime::new()?; + runtime.set_memory_limit(QUICKJS_MEMORY_LIMIT).await; let context = AsyncContext::full(&runtime).await?; // Create shared state for async ops if we have a client