Skip to content

Commit

Permalink
fix: error array index skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
kgmyatthu authored and mhanson-github committed Aug 16, 2024
1 parent 385a195 commit b0b7cf0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions shardus_net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,15 @@ pub fn multi_send_with_header(mut cx: FunctionContext) -> JsResult<JsUndefined>
nodejs_thread_channel.send(move |mut cx| {
let cx = &mut cx;

let stats = this.to_inner(cx).get::<JsBox<RefCell<Stats>>, _, _>(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::<JsBox<RefCell<Stats>>, _, _>(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;
}
}

Expand Down

0 comments on commit b0b7cf0

Please sign in to comment.