@@ -246,7 +246,10 @@ impl JsAgent {
246246 . map_err ( |e| anyhow:: anyhow!( "Lock poisoned: {}" , e) ) ?;
247247 * limit = max_mem;
248248
249- info ! ( memory_limit_mb = max_mem / ( 1024 * 1024 ) , "Memory limit updated" ) ;
249+ info ! (
250+ memory_limit_mb = max_mem / ( 1024 * 1024 ) ,
251+ "Memory limit updated"
252+ ) ;
250253 }
251254
252255 // Rebuild cached context if script changed
@@ -363,42 +366,43 @@ impl JsAgent {
363366 . as_ref ( )
364367 . ok_or_else ( || anyhow:: anyhow!( "No cached context available" ) ) ?;
365368
366- ctx_ref. with ( |ctx| {
367- // Check if function exists (already defined from cached script eval)
368- let globals = ctx. globals ( ) ;
369- let func: Option < Function > = globals. get ( fn_name) . ok ( ) ;
369+ ctx_ref
370+ . with ( |ctx| {
371+ // Check if function exists (already defined from cached script eval)
372+ let globals = ctx. globals ( ) ;
373+ let func: Option < Function > = globals. get ( fn_name) . ok ( ) ;
370374
371- let Some ( func) = func else {
372- debug ! ( function = fn_name, "Function not defined in script" ) ;
373- return Ok ( None ) ;
374- } ;
375+ let Some ( func) = func else {
376+ debug ! ( function = fn_name, "Function not defined in script" ) ;
377+ return Ok ( None ) ;
378+ } ;
375379
376- // Convert argument to JS value
377- let js_arg = Self :: json_to_js ( & ctx, & arg) ?;
380+ // Convert argument to JS value
381+ let js_arg = Self :: json_to_js ( & ctx, & arg) ?;
378382
379- // Call the function
380- let result: Value = func. call ( ( js_arg, ) ) ?;
383+ // Call the function
384+ let result: Value = func. call ( ( js_arg, ) ) ?;
381385
382- // Convert result to ScriptResult
383- let json_result = Self :: js_to_json ( & result) ;
386+ // Convert result to ScriptResult
387+ let json_result = Self :: js_to_json ( & result) ;
384388
385- if json_result. is_null ( ) {
386- return Ok ( Some ( ScriptResult {
387- decision : "allow" . to_string ( ) ,
388- ..Default :: default ( )
389- } ) ) ;
390- }
389+ if json_result. is_null ( ) {
390+ return Ok ( Some ( ScriptResult {
391+ decision : "allow" . to_string ( ) ,
392+ ..Default :: default ( )
393+ } ) ) ;
394+ }
391395
392- let script_result: ScriptResult =
393- serde_json:: from_value ( json_result) . map_err ( |e| rquickjs:: Error :: FromJs {
394- from : "object" ,
395- to : "ScriptResult" ,
396- message : Some ( format ! ( "Failed to parse result: {}" , e) ) ,
397- } ) ?;
396+ let script_result: ScriptResult =
397+ serde_json:: from_value ( json_result) . map_err ( |e| rquickjs:: Error :: FromJs {
398+ from : "object" ,
399+ to : "ScriptResult" ,
400+ message : Some ( format ! ( "Failed to parse result: {}" , e) ) ,
401+ } ) ?;
398402
399- Ok ( Some ( script_result) )
400- } )
401- . map_err ( |e : rquickjs:: Error | anyhow:: anyhow!( "JavaScript error: {}" , e) )
403+ Ok ( Some ( script_result) )
404+ } )
405+ . map_err ( |e : rquickjs:: Error | anyhow:: anyhow!( "JavaScript error: {}" , e) )
402406 }
403407
404408 /// Build AgentResponse from ScriptResult
@@ -825,10 +829,9 @@ impl AgentHandlerV2 for JsAgent {
825829 let total = self . requests_total . load ( Ordering :: Relaxed ) ;
826830 let errors = self . script_errors . load ( Ordering :: Relaxed ) ;
827831
828- report. counters . push ( CounterMetric :: new (
829- "js_agent_requests_total" ,
830- total,
831- ) ) ;
832+ report
833+ . counters
834+ . push ( CounterMetric :: new ( "js_agent_requests_total" , total) ) ;
832835
833836 report. counters . push ( CounterMetric :: new (
834837 "js_agent_requests_allowed_total" ,
@@ -840,10 +843,9 @@ impl AgentHandlerV2 for JsAgent {
840843 self . requests_blocked . load ( Ordering :: Relaxed ) ,
841844 ) ) ;
842845
843- report. counters . push ( CounterMetric :: new (
844- "js_agent_script_errors_total" ,
845- errors,
846- ) ) ;
846+ report
847+ . counters
848+ . push ( CounterMetric :: new ( "js_agent_script_errors_total" , errors) ) ;
847849
848850 // Gauges
849851 let error_rate = if total > 0 {
0 commit comments