From b0b7cf0eae5d9f9685efec136e5248df04a6eb58 Mon Sep 17 00:00:00 2001 From: Kaung Myat Thu <2962000kaungmyatthu@gmail.com> Date: Tue, 16 Jul 2024 18:30:21 +0700 Subject: [PATCH] fix: error array index skipping --- shardus_net/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shardus_net/src/lib.rs b/shardus_net/src/lib.rs index 4682cd3..9d607f4 100644 --- a/shardus_net/src/lib.rs +++ b/shardus_net/src/lib.rs @@ -339,13 +339,15 @@ pub fn multi_send_with_header(mut cx: FunctionContext) -> JsResult nodejs_thread_channel.send(move |mut cx| { let cx = &mut cx; + let stats = this.to_inner(cx).get::>, _, _>(cx, "_stats")?; let js_arr = cx.empty_array(); + let mut error_count = 0; for i in 0..results.len() { - let stats = this.to_inner(cx).get::>, _, _>(cx, "_stats")?; (**stats).borrow_mut().decrement_outstanding_sends(); if let Err(err) = &results[i] { let err = cx.string(format!("{:?}", err)); - js_arr.set(cx, i as u32, err)?; + js_arr.set(cx, error_count, err)?; + error_count += 1; } }