Closed sontixyou closed 1 month ago
This is caused by https://github.com/cloudflare/workers-rs/issues/617
Can you try pinning js_sys
in your Cargo.toml
?
I try pinning js_sys version
error[E0599]: no method named `unwrap` found for struct `js_sys::Iterator` in the current scope
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/headers.rs:69:14
|
66 | / self.0
67 | | .entries()
68 | | // Header.entries() doesn't error: https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries
69 | | .unwrap()
| | -^^^^^^ method not found in `Iterator`
| |_____________|
|
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/http/header.rs:11:16
|
11 | for res in from_headers.entries()?.into_iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `js_sys::Iterator`
|
= help: the trait `Try` is not implemented for `js_sys::Iterator`
Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `worker` (lib) due to 2 previous errors
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
full command: cd "/Users/user_name/projects/rust-projects/first_rusty_worker" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
Error: wasm-pack exited with status exit status: 1
β [ERROR] Running custom build `cargo install -q worker-build && worker-build --release` failed. There are likely more logs from your build command above.
πͺ΅ Logs were written to "/Users/user_name/Library/Preferences/.wrangler/logs/wrangler-2024-08-17_12-28-11_661.log"
@kflansburg
I tried pin that crate version. https://github.com/sontixyou/first_rusty_worker/commit/43a93e97ca5fde51f7f72ce697db13cfd0445152
But I can't pin version of js-sys
crate.
Because js-sys
crate depends wasm-bindgen
. wasm-bindgen
crate pinn js-sys
ver 0.3.70.
https://github.com/sontixyou/build_error_worker/blob/43a93e97ca5fde51f7f72ce697db13cfd0445152/Cargo.lock#L292
ref: https://github.com/rustwasm/wasm-bindgen/blob/main/crates/js-sys/Cargo.toml#L17 commit ref: https://github.com/rustwasm/wasm-bindgen/commit/bf9807c5a0c593cf03a5f648b93a738e74fce1d0#diff-2ea8bb4c7962b2dd1eeccf6f96b030787bfec583a77f3a76a9a43ba3c95fef6b
I pinned wasm-bindgen
crate and it still failed to compile.
wasm-bindgen = "0.2.92"
You need:
wasm-bindgen = "=0.2.92"
Cargo will automatically pull in newer patch versions otherwise.
Thank you. I tried two methods. I was able to run a local server. But I'd like to run it on the latest version of the crate.
Is it correct that this worker-rs
crate needs some kind of change?
ref : https://github.com/cloudflare/workers-rs/issues/620#issuecomment-2294882873
I install these crates succeessfully.
error[E0599]: no method named `unwrap` found for struct `js_sys::Iterator` in the current scope
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/headers.r
s:85:24
|
85 | .map(|a| a.unwrap().as_string().unwrap())
| ^^^^^^ method not found in `Iterator`
error[E0599]: no method named `unwrap` found for struct `js_sys::Iterator` in the current scope
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/headers.r
s:97:24
|
97 | .map(|a| a.unwrap().as_string().unwrap())
| ^^^^^^ method not found in `Iterator`
error[E0631]: type mismatch in function arguments
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/headers.
rs:71:18
|
71 | .map((|a| a.unwrap().into()) as F1)
| --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected due to this
| | found signature defined here
| required by a bound introduced by this call
|
= note: expected function signature `fn(js_sys::Iterator) -> _`
found function signature `fn(std::result::Result<wasm_bindgen::JsValue, wasm_bindge
n::JsValue>) -> _`
note: required by a bound in `std::iter::Iterator::map`
--> /Users/user_name/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/co
re/src/iter/traits/iterator.rs:764:12
|
761 | fn map<B, F>(self, f: F) -> Map<Self, F>
| --- required by a bound in this associated function
...
764 | F: FnMut(Self::Item) -> B,
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::map`
error[E0599]: the method `map` exists for struct `Map<IntoIter<Iterator>, fn(Result<JsValue, JsVal
ue>) -> Array>`, but its trait bounds were not satisfied
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/headers.r
s:73:14
|
66 | / ... self.0
67 | | ... .entries()
68 | | ... // Header.entries() doesn't error: https://developer.mozilla.org/en-US/docs/We...
69 | | ... .into_iter()
... |
72 | | ... // The entries iterator always returns an array[2] of strings
73 | | ... .map(|a: Array| (a.get(0).as_string().unwrap(), a.get(1).as_string().unwrap()))
| | -^^^ method cannot be called due to unsatisfied trait bounds
| |___________|
|
|
::: /Users/user_name/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/cor
e/src/iter/adapters/map.rs:62:1
|
62 | pub struct Map<I, F> {
| -------------------- doesn't satisfy `_: Iterator`
|
= note: the full type name has been written to '/Users/user_name/projects/rust-projects/first_rusty
_worker/target/wasm32-unknown-unknown/release/deps/worker-e89e2ad91ae39750.long-type-3619179159829
353566.txt'
= note: consider using `--verbose` to print the full type name to the console
= note: the following trait bounds were not satisfied:
`<fn(std::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Arra
y as FnOnce<(js_sys::Iterator,)>>::Output = _`
which is required by `std::iter::Map<std::result::IntoIter<js_sys::Iterator>, fn(std::r
esult::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Array>: std::iter::Iterato
r`
`fn(std::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Array
: FnMut<(js_sys::Iterator,)>`
which is required by `std::iter::Map<std::result::IntoIter<js_sys::Iterator>, fn(std::r
esult::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Array>: std::iter::Iterato
r`
`std::iter::Map<std::result::IntoIter<js_sys::Iterator>, fn(std::result::Result<wasm_bi
ndgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Array>: std::iter::Iterator`
which is required by `&mut std::iter::Map<std::result::IntoIter<js_sys::Iterator>, fn(s
td::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>) -> js_sys::Array>: std::iter::It
erator`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> /Users/user_name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/worker-0.3.3/src/http/head
er.rs:13:24
|
13 | let a: Array = res?.into();
| ^^^^ the `?` operator cannot be applied to type `js_sys::Iterator`
|
= help: the trait `Try` is not implemented for `js_sys::Iterator`
Some errors have detailed explanations: E0277, E0599, E0631.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `worker` (lib) due to 5 previous errors
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
full command: cd "/Users/user_name/projects/rust-projects/first_rusty_worker" && "cargo" "build" "--
lib" "--release" "--target" "wasm32-unknown-unknown"
Error: wasm-pack exited with status exit status: 1
β [ERROR] Running custom build `cargo install -q worker-build && worker-build --release` failed. T
here are likely more logs from your build command above.
ref : https://github.com/sontixyou/first_rusty_worker/commit/b896420dd9007c192115ce6f441d5b4ee4265385
I executed npx wrangler dev
successfully.
Is there an existing issue for this?
What version of
workers-rs
are you using?0.3.3 features = ['http', 'axum']
What version of
wrangler
are you using?3.72.0
Describe the bug
Observed behavior
Compilation error when running
npx wrangler dev
commandExpected behavior
Compilation successfully and run local server on localhost:8787 when running
npx wrangler dev
command.Steps To Reproduce
Minimal repo is here. https://github.com/sontixyou/first_rusty_worker
I note the log output from my execution of the command. I executed
cargo generate cloudflare/workers-rs
command.Next I executed
npx wrangler dev
command