Skip to content

Commit

Permalink
fix: Don't try to queue tasks after Runtime is dropped causing panics
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbot95 committed Mar 18, 2024
1 parent 2b86062 commit 99f9ac1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion screeps-async/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ impl ScreepsRuntime {

let sender = self.sender.clone();
let (runnable, task) = async_task::spawn_local(future, move |runnable| {
sender.send(runnable).unwrap();
// Don't try to send if disconnected, this only happens when runtime is being dropped
if !sender.is_disconnected() {
sender.send(runnable).unwrap();
}
});

runnable.schedule();
Expand Down

0 comments on commit 99f9ac1

Please sign in to comment.