Skip to content
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

Fix jitter causing panics on wasm32-unknown-unknown #2

Merged
merged 1 commit into from
May 30, 2020
Merged

Fix jitter causing panics on wasm32-unknown-unknown #2

merged 1 commit into from
May 30, 2020

Conversation

Zireael-N
Copy link
Contributor

getrandom, which rand depends on, needs to know how to interface with JS in order to work. Otherwise, it causes an "unreachable" error:

https://github.com/rust-random/getrandom/tree/0ad1c7721455b644a775bb4647806ab631250c14#features

@@ -20,6 +20,9 @@ categories = [
maintenance = { status = "actively-developed" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
wasm-bindgen = ["rand/wasm-bindgen"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zireael-N does this relate to your other pull?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to better understand how to catch these errors. I'm new to the wasm world so I may do something run but wouldn't this catch it?

run: cargo build --target wasm32-unknown-unknown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a runtime error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the easiest thing you can do is to make CI build a wasm binary and then attempt to interface with it via NodeJS to see if it throws an exception.

Copy link
Contributor Author

@Zireael-N Zireael-N May 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this won't work with NodeJS because wasm-timer assumes that it's being run in a browser and expects window to be available. :(

wasm-bindgen, according to its guide, can run tests using headless browsers but I've never done that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this thread might be helpful. it seems possible to get rand working with wasm bindgen. I'll do some research rust-random/rand#616

Copy link
Contributor Author

@Zireael-N Zireael-N May 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work if you use the wasm-bindgen feature. The features I added in this PR just tell cargo to enable corresponding features while compiling rand.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha rust-random/rand#810 (comment) I was missing a bit of context here. Can you merge master to fix the merge conflict. I'll merge this aftet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and force-pushed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll follow up on figuring out what an integration test looks like this in ci in #4

@softprops softprops merged commit 40b07a8 into softprops:master May 30, 2020
@softprops
Copy link
Owner

thanks for your patches @Zireael-N I just published a new version with your other change and a new version with this change should be on its way to crates.io shortly https://github.com/softprops/again/actions/runs/120210531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants