Skip to content

Commit

Permalink
fix(runtime): avoid thread panicking when promise id not found (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz authored Feb 27, 2023
1 parent 056aefa commit 046d04f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-cows-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lagon/runtime': patch
---

Avoid thread panicking when promise id is not found
9 changes: 3 additions & 6 deletions crates/runtime_isolate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,9 @@ impl Isolate {
while let Poll::Ready(Some(BindingResult { id, result })) =
isolate_state.promises.poll_next_unpin(cx)
{
let promise = isolate_state
.js_promises
.remove(&id)
.unwrap_or_else(|| panic!("JS promise {id} not found"));

promises.as_mut().unwrap().push((result, promise));
if let Some(promise) = isolate_state.js_promises.remove(&id) {
promises.as_mut().unwrap().push((result, promise));
}
}

self.running_promises.store(false, Ordering::SeqCst);
Expand Down

0 comments on commit 046d04f

Please sign in to comment.