-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gloo-timers 0.2.3 can panic #187
Comments
I can't reproduce this behavior locally with trunk. # Cargo.toml
[package]
name = "gloo-timers-regression"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
gloo-timers = "0.2.3"
gloo-console = "*" // src/main.rs
#[macro_use]
extern crate gloo_console;
use gloo_timers::callback::Timeout;
const DELAY_MILLIS: u32 = 30;
fn main() {
log!("hello");
let tt = Timeout::new(DELAY_MILLIS, move || { log!("inside") });
drop(tt);
} I used |
Since it works under trunk, I think it's safe to say that it's not a problem with gloo-timers |
I guess it depends on the definition of "a problem with gloo-timers". The gloo-timers crate used to work under webpack and now it doesn't. I've created a globals branch of my demo that illustrates that calling the "global" FWIW, my app's use of gloo-timers is relatively small, so if there's no desire to go back to code that works with webpack, I can leave gloo-timers pegged to 0.2.2 for now and then just rewrite the subset of functionality that I use. I can't trivially switch from webpack to trunk though. Nor do I have enough knowledge of the JavaScript ecosystem to look much deeper into this issue. |
I wonder if this is an issue with wasm-pack. Webpack calls wasm-pack to bundle the Rust app |
It could be. However, the presence of |
The CI passes. I have a feeling it might be a wasm-pack bug. I will confirm later |
Can confirm - getting the same error with |
@ivanschuetz I forked and quickly hacked in a proof-of-concept fix in my js_sys-experiment branch. If that branch works for you, I'll be happy to turn it into a PR, perhaps behind a feature flag. Currently I've just pinned |
Seems there's a bug with wasm-pack, that happens since gloo timers was upgraded to 0.2.3, see rustwasm/gloo#187
Perhaps one of you can try |
Thanks for looking into it. I tried using:
in my Cargo.toml, but cargo (and my own repository forked from rustwasm) claims that's not a commit. I see where that commit is referenced in the pull-request, but I think it may have been squashed when it went into master. I tried looking in PhilippGackstatter for the `branch that it came from, but without success. Based on my previous experience, that commit would not work, because it contains:
which seems to cause a panic when used with wasm-pack, which is why I have
in my fork that doesn't panic when using wasm-pack. |
I should have said "probably would not work", because dealing with globals is always tricky and there may be something in your commit that sets something up so that the JavaScript |
I'm getting this error with wasm-pack with version 0.2.4 of gloo-timers. |
@bnheise I wish I had more time to look into this further, but I haven't been able to make the time, although in part that's because it appeared like it was biting so few people that I could just live with my own branch:
The biggest thing that's holding me back is that I simply don't have enough domain knowledge to be able to do anything beyond what I've already done without doing a lot of research. Perhaps @hamza1311 can confirm (or refute) that this is a wasm-pack bug. |
The issue seems to be the build with In case anyone knows why this might be, I would like to hear that. I'm not sure about the history of @ctm, can the issue be solved |
Thanks for looking into this guys. It might take me a few days, but I can test out |
@hamza1311 Thanks! I don't know how to use those flags off the top of my head, but I'll poke around and either give you an answer or ask you some questions soon (probably later today). |
@hamza1311, thanks for the quick response. Initially I tried blindly adding
I then read a bit about what the different targets mean and found:
which precludes me from using it in my software, because my software does indeed have NPM dependencies. It looks to me like |
* fix: `clearTimeout` illegal invocation in browser (#187) * fix: return type of `Timeout/Interval` accepts both number and `NodeJS.Timeout` * chore: simplify clearTimeout/clearInterval binding refer #283 (comment) for background * CI: setup node tests
Describe the Bug
Code using gloo-timers 0.2.3 can panic when the timer is dropped.
Steps to Reproduce
If applicable, add a link to a test case (as a zip file or link to a repository
we can clone).
Expected Behavior
There should be no panic.
Actual Behavior
There is a panic.
Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: