Skip to content

Commit

Permalink
Web: fix crash with ControlFlow::Wait|WaitUntil
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Mar 2, 2024
1 parent 1c5fcf3 commit 8d66df7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ PR's changelog entry would go into the wrong section).
And please only add new entries to the top of this list, right below the `#
Unreleased` header.

# Unreleased
# 0.29.13

- On Web, fix possible crash with `ControlFlow::Wait` and `ControlFlow::WaitUntil`.

# 0.29.12

Expand Down
5 changes: 2 additions & 3 deletions src/platform_impl/web/web_sys/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ impl Schedule {
let channel = MessageChannel::new().unwrap();
let closure = Closure::new(f);
let port_1 = channel.port1();
port_1
.add_event_listener_with_callback("message", closure.as_ref().unchecked_ref())
.expect("Failed to set message handler");
port_1.set_onmessage(Some(closure.as_ref().unchecked_ref()));
port_1.start();

let port_2 = channel.port2();
Expand Down Expand Up @@ -178,6 +176,7 @@ impl Drop for Schedule {
} => {
window.clear_timeout_with_handle(*handle);
port.close();
port.set_onmessage(None);
}
}
}
Expand Down

0 comments on commit 8d66df7

Please sign in to comment.