stalwartlabs / jmap-client

JMAP client library for Rust
Apache License 2.0
62 stars 8 forks source link

Fairly random errors when compiling to `wasm32-unknown-unknown` target. #4

Open maltalef101 opened 1 year ago

maltalef101 commented 1 year ago

I use WASM on the browser and when compiling I get some errors that really seem to come out of nowhere.

When bulding exactly the same crate with cargo build --target x86_64-unknown-linux-gnu the before mentioned errors magically disappear.

These are the bastards:

error[E0432]: unresolved import `reqwest::redirect`
  --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/client.rs:24:5
   |
24 |     redirect,
   |     ^^^^^^^^ no `redirect` in the root

error[E0599]: no method named `timeout` found for struct `ClientBuilder` in the current scope
  --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/blob/download.rs:53:18
   |
53 |                 .timeout(Duration::from_millis(self.timeout()))
   |                  ^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `redirect` found for struct `ClientBuilder` in the current scope
   --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/client.rs:369:22
    |
369 |                     .redirect(self.redirect_policy())
    |                      ^^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `timeout` found for struct `ClientBuilder` in the current scope
  --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/blob/upload.rs:62:22
   |
62 |                     .timeout(Duration::from_millis(self.timeout()))
   |                      ^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `timeout` found for struct `ClientBuilder` in the current scope
   --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/client.rs:147:22
    |
147 |                     .timeout(Duration::from_millis(self.timeout))
    |                      ^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `timeout` found for struct `ClientBuilder` in the current scope
   --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/client.rs:421:22
    |
421 |                     .timeout(Duration::from_millis(DEFAULT_TIMEOUT_MS))
    |                      ^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `connect_timeout` found for struct `ClientBuilder` in the current scope
  --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/event_source/stream.rs:76:18
   |
76 |                 .connect_timeout(Duration::from_millis(self.timeout()))
   |                  ^^^^^^^^^^^^^^^ method not found in `ClientBuilder`

error[E0599]: no method named `bytes_stream` found for struct `Response` in the current scope
  --> /home/maltalef/.local/share/cargo/registry/src/github.com/jmap-client-0.2.0/src/event_source/stream.rs:85:10
   |
85 |         .bytes_stream();
   |          ^^^^^^^^^^^^ method not found in `Response`

If I recall correctly, reqwest added support for WASM some time ago, so I don't have any idea about what is causing the first error. I've found all those unresolved modules locally by exploring the local library clones.

In general, I suspect I've thrown sonething at this library for which it wasn't prepared for. I am really lost in this issue.

Any help is greatly appreciated. Regards.

maltalef101 commented 1 year ago

Some of these errors seem to disappear when specifying the dependency with no-default-features enabled, so the async features don't get enabled and async code isn't compiled. Keep in mind you also have to enable the blocking feature.

mdecimus commented 1 year ago

The JMAP client uses a forked version of reqwest 0.11 that supports following redirects to trusted hosts. The PR for this feature was submitted months ago but never merged into reqwest's main branch. So for the time being any new releases made to reqwest will have to be merged manually.

I haven't tried compiling JMAP client for WASM but if blocking support is required then some features such as EventSource and WebSocket won't be available.