Skip to main content

Crate camel_language_js

Crate camel_language_js 

Source
Expand description

JavaScript language plugin for Apache Camel Rust.

Provides JsLanguage — a Language implementation backed by the Boa JavaScript engine.

§Resource Limits

Scripts are bounded by configurable limits sourced from [languages.js.limits] in Camel.toml. When absent, rust-camel runtime defaults apply:

LimitDefaultSource
execution-timeout-ms5,000tokio::time::timeout + spawn_blocking
max-loop-iterations100,000Boa RuntimeLimits::set_loop_iteration_limit
max-recursion-depth512Boa RuntimeLimits::set_recursion_limit
max-stack-size10,240 slotsBoa RuntimeLimits::set_stack_size_limit

§Covered threats

  • Infinite loops (while (true) {}) — trip max-loop-iterations.
  • Deep recursion — trips max-recursion-depth.
  • Stack exhaustion — trips max-stack-size.
  • Wall-clock stalls — bounded by execution-timeout-ms.

§NOT covered

Heap capboa_engine 0.21 does not expose a heap-size limit. A script that allocates many small objects can exhaust process memory before any other limit trips. Route authors writing JS that allocates heavily should validate their scripts carefully; untrusted JS should use function: (ADR-0005, out-of-process) instead of js:/javascript:.

§Timeout caveat

Same as Rhai: when execution-timeout-ms fires, the route future resolves to an error, but the blocking thread may continue executing until a RuntimeLimits bound trips or the script finishes.

Re-exports§

pub use engines::BoaEngine;
pub use error::JsLanguageError;

Modules§

engines
error
value
Conversions between serde_json::Value and boa_engine::JsValue.

Structs§

JsEvalResult
The result of evaluating a JS expression.
JsExchange
A snapshot of exchange state passed into and out of JS evaluation.
JsLanguage
JavaScript language plugin backed by Boa.

Traits§

JsEngine
Abstraction over a JavaScript engine capable of evaluating expressions against a JsExchange context.