getsentry / sentry-rust

Official Sentry SDK for Rust
https://sentry.io/
Apache License 2.0
598 stars 147 forks source link

Wasm support? #226

Open MTRNord opened 4 years ago

MTRNord commented 4 years ago

Hi wasm based rust currently fails in all kind of ways.

Especially this often happens when compiling:

error[E0599]: no method named `as_sock` found for reference `&udp::UdpBuilder` in the current scope
    --> /home/marcel/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.34/src/ext.rs:1558:22
     |
1558 |         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
     |                      ^^^^^^^ method not found in `&udp::UdpBuilder`

Is it possible to get wasm support in the future?

Swatinem commented 4 years ago

We actually talked about this internally a few days ago. So far we haven’t tried it, and I don’t think it will be a priority any time soon. However, the new modularized sentry-core should be a much better starting point for this.

MTRNord commented 4 years ago

It would be awesome at some point :) (Especially as I currently work with yew/wasm)

Diggsey commented 2 years ago

Has there been any movement on this issue? :) I see there are some Wasm related types in the documentation.

GeeWee commented 2 years ago

I know that leaving +1's are generally a bad practice, but I wanted to mention that particularly now that serving API's via WASM through Fastly or CloudFlare, this is a missing piece that would be very nice to have.

hut8 commented 1 year ago

I'll be digging through this shortly to see if anything has changed, but has anyone even tried recently? If I add these lines to my wasm project, I don't get any errors:

sentry = {version = "0.29.1", default-features = false}
getrandom = { version = "0.2.8", features = ["js"] }

The second line is necessary because sentry requires getrandom but does not set the js feature, which is necessary to get random numbers from a wasm (in JS) context. If I don't set default-features = false in sentry then the first error I get is about not having OpenSSL headers, and obviously that is not happening in a WASM context. But I see that reqwest does support WASM, so that stuff shouldn't be necessary...

omarabid commented 1 year ago

@hut8 I got it working. However, using the sentry package, you have to do all the serializing of data manually (and I think this will be platform specific too, I'm working on CloudFlare workers). If this is of interest to you and you are interested to working on it, reach me by email.

hut8 commented 1 year ago

It looks like no matter what, I can't use the sentry crate at all, and I believe that's @omarabid 's experience too. I get a panic here:

 at std::time::SystemTime::now::h69200a4ca613d8a5
 at sentry_types::auth::auth_from_dsn_and_client::h4dc5020090240e03

For a browser WASM environment, I think we would have to do a rather large overhaul.

However, the ureq transport at least builds 😄

ChrisB9 commented 1 year ago

@hut8 thanks to you I actually got sentry to build too, but then in the browser its not going to start at all, as if sentry is completely blocking the dioxus web initializer code.

rednaks commented 1 year ago

on my side I have issues with "time". I get this error:

time not implemented on this platform', library/std/src/sys/wasm/../unsupported/time.rs:31:9