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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃摑 caveat when upgrading to worker 0.0.18 #400

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

vikiival
Copy link
Contributor

@vikiival vikiival commented Oct 3, 2023

Context

We (@kodadot) are huge fans of Cloudflare and Workers and we have a ton of workers in the prod (Rust / TS).

As anyone would upgrade to latest version they would meet this very scary error

[INFO]: 馃寑  Compiling to Wasm...
   Compiling proc-macro2 v1.0.67
   Compiling phf_shared v0.11.1
   Compiling serde v1.0.164
   Compiling syn v1.0.109
   Compiling unicode-normalization v0.1.22
   Compiling mio v0.8.8
   Compiling matchit v0.4.6
error[E0432]: unresolved import `crate::sys::IoSourceState`

The only mention I found was in Cloudlfare's discord

Screenshot 2023-10-03 at 17 34 25

Copy link
Member

@kflansburg kflansburg left a comment

Choose a reason for hiding this comment

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

It might make sense to note that we require 2021 edition at the top as well, but this looks good for now

@kflansburg kflansburg merged commit 73a127c into cloudflare:main Nov 8, 2023
1 check passed
@vikiival vikiival deleted the patch-1 branch November 8, 2023 18:53
jdon pushed a commit to jdon/workers-rs that referenced this pull request Mar 27, 2024
@joelawm
Copy link

joelawm commented May 28, 2024

@kflansburg I believe this advice may be outdated or not clear enough

name = "backend"
main = "build/worker/shim.mjs"
compatibility_date = "2024-05-22"


[build]
command = "cargo install -q worker-build && worker-build --release"

[package]
edition = "2021"

This errors with "Additional properties are not allowed ('package' was unexpected)" and does nothing to remedy the original problem. Any help would be amazing!

@avsaase
Copy link
Contributor

avsaase commented May 28, 2024

Your Cargo.toml is not valid. Change it to this:

[package]
name = "backend"
main = "build/worker/shim.mjs"
compatibility_date = "2024-05-22"
edition = "2021"

[build]
command = "cargo install -q worker-build && worker-build --release"

@joelawm
Copy link

joelawm commented May 28, 2024

@avsaase The original PR says wrangler.toml

In this case, upgrade package.edition to edition = "2021" in wrangler.toml

My cargo.toml has this and its not compiling mio with same error set as above. We may need to reopen this or create a new thread unless im still missing something.

@avsaase
Copy link
Contributor

avsaase commented May 28, 2024

That can't be correct. My example isn't either though. The edition field should be added to the [package] section of your Cargo.toml file.

@joelawm
Copy link

joelawm commented May 28, 2024

Here is my projects Toml file.

[package]
name = "backend"
version = "0.1.0"
edition = "2021"
authors = [ "Joe Meyer <joemeyer@lavabit.com>" ]

[package.metadata.release]
release = false

# https://github.com/rustwasm/wasm-pack/issues/1247
[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[lib]
crate-type = ["cdylib"]

[dependencies]
worker = { version="0.3.0", features=['http', 'axum'] }
worker-macros = { version="0.3.0", features=['http'] }
axum  = { version = "0.7" }
tower-service = "0.3.2"
console_error_panic_hook = { version = "0.1.1" }
tracing = "0.1.37"
serde_derive = "1.0.174"
serde = { version = "1.0.174", features = ["derive"]}
lazy_static = "1.4.0"
email = {path = "../email"}

I also have resolver = "2" set in the Cargo.toml workspace which some other issues related have suggesed.

Resuts in

error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9
    |
342 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
343 | |                         default, you may need to enable the \"js\" feature. \
344 | |                         For more information see: \
345 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0432]: unresolved import `crate::sys::IoSourceState`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/io_source.rs:12:5
   |
12 | use crate::sys::IoSourceState;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ no `IoSourceState` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/tcp/listener.rs:15:17
   |
15 | use crate::sys::tcp::{bind, listen, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/tcp/stream.rs:13:17
   |
13 | use crate::sys::tcp::{connect, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `Selector` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:312:18
    |
312 |             sys::Selector::new().map(|selector| Poll {
    |                  ^^^^^^^^ could not find `Selector` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:24:14
   |
24 |         sys::event::token(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:38:14
   |
38 |         sys::event::is_readable(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:43:14
   |
43 |         sys::event::is_writable(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:68:14
   |
68 |         sys::event::is_error(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:99:14
   |
99 |         sys::event::is_read_closed(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:129:14
    |
129 |         sys::event::is_write_closed(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:151:14
    |
151 |         sys::event::is_priority(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:173:14
    |
173 |         sys::event::is_aio(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:183:14
    |
183 |         sys::event::is_lio(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/event/event.rs:221:26
    |
221 |                     sys::event::debug_details(f, self.0)
    |                          ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `tcp` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/tcp/listener.rs:103:18
    |
103 |             sys::tcp::accept(inner).map(|(stream, addr)| (TcpStream::from_std(stream), addr))
    |                  ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `udp` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/udp.rs:122:14
    |
122 |         sys::udp::bind(addr).map(UdpSocket::from_std)
    |              ^^^ could not find `udp` in `sys`

error[E0433]: failed to resolve: could not find `udp` in `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/udp.rs:544:14
    |
544 |         sys::udp::only_v6(&self.inner)
    |              ^^^ could not find `udp` in `sys`

error[E0412]: cannot find type `Selector` in module `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:263:20
    |
263 |     selector: sys::Selector,
    |                    ^^^^^^^^ not found in `sys`

error[E0412]: cannot find type `Selector` in module `sys`
   --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/poll.rs:710:44
    |
710 |     pub(crate) fn selector(&self) -> &sys::Selector {
    |                                            ^^^^^^^^ not found in `sys`

error[E0412]: cannot find type `Waker` in module `sys`
  --> /Users/deltagi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/waker.rs:79:17
   |
79 |     inner: sys::Waker,
   |                 ^^^^^ not found in `sys`
   |
help: consider importing one of these items
   |
1  + use core::task::Waker;
   |
1  + use crate::Waker;
   |
1  + use std::task::Waker;
   |
help: if you import `Waker`, refer to it directly
   |
79 -     inner: sys::Waker,
79 +     inner: Waker,
......

@avsaase
Copy link
Contributor

avsaase commented May 28, 2024

I suspect axum pulls in tokio which doesn't compile to wasm. Try changing your dependency to

axum  = { version = "0.7", default-features = false }

You may need to manually re-enable some of the features listed here.

@joelawm
Copy link

joelawm commented May 29, 2024

@avsaase thank you that fixed the problem, though I was still having issues with socket2 haha, I'll have to end up going to a non wasm solution unfortunately thank you for the help!

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.

None yet

4 participants