I used a blocking reqwest call in tokio's async without std::thread::spawn. This should give an error when running. But it does build and run successfully with the target wasm32-wasmer-wasi.
PORT=3000 cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Running `target/debug/news-scraper`
Listening on 127.0.0.1:3000
Try to curl it:
curl localhost:3000
curl: (52) Empty reply from server
while in the project's terminal:
thread 'tokio-runtime-worker' panicked at 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.', /Users/xorcist/.cargo/git/checkouts/tokio-2eb71367495b4da5/2be2588/tokio/src/runtime/blocking/shutdown.rs:51:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
But the same behaviour doesn't exist in wasm32-wasmer-wasi / WASIX:
Running with wasmer:
wasmer run target/wasm32-wasmer-wasi/release/news-scraper.wasm --net --env PORT=3000
Listening on 127.0.0.1:3000
And trying to curl it:
curl localhost:3000
Hacker News
1. Things you forgot because of React
134 points by inner_square 2 hours ago | 90 comments
https://joshcollinsworth.com/blog/antiquated-react
It shows the news!
But if you curl it again:
curl localhost:3000
It won't work!, just keeps on waiting.
The trace for the second curl request in the project's terminal shows:
2023-08-15T11:53:33.877947Z DEBUG ThreadId(13) wasmer_wasix::syscalls::wasix::thread_spawn: failed with runtime error: RuntimeError: out of bounds memory access
Context
The issue was discovered while making the news-scraper for wasmer edge.
https://github.com/wasix-org/wasix-rust-examples/tree/01d27bd5b2910bb3e4b97561f94c6e25fc183e7d/news-web-scraper
The problem:
I used a blocking
reqwest
call in tokio's async withoutstd::thread::spawn
. This should give an error when running. But it does build and run successfully with the targetwasm32-wasmer-wasi
.https://github.com/wasix-org/wasix-rust-examples/blob/01d27bd5b2910bb3e4b97561f94c6e25fc183e7d/news-web-scraper/src/main.rs#L8-L20
https://github.com/wasix-org/wasix-rust-examples/blob/01d27bd5b2910bb3e4b97561f94c6e25fc183e7d/news-web-scraper/src/news_scraper.rs#L52-L55
Steps to reproduce:
Running with native
cargo run
:Try to curl it:
while in the project's terminal:
But the same behaviour doesn't exist in
wasm32-wasmer-wasi
/ WASIX:Running with wasmer:
And trying to curl it:
It shows the news! But if you curl it again:
It won't work!, just keeps on waiting.
The trace for the second curl request in the project's terminal shows:
The important thing to see here:
2023-08-15T11:53:33.877947Z DEBUG ThreadId(13) wasmer_wasix::syscalls::wasix::thread_spawn: failed with runtime error: RuntimeError: out of bounds memory access