bytecodealliance / bytecodealliance/wstd
wstd::main doesn't set exit code on failure
- 主要言語
- Rust
- スター
- 133
- フォーク
- 19
- 平均マージ
- 6日 19時間
- マージ済み PR(30日)
- 5
説明
When using the `#[wstd::main]` i would expect that an error would set another exitcode than 0.
This beavior is the same right now as tokio::main in a none wasm-application.
Example usage:
```rust
use std::error::Error;
use wstd::http::{Body, Client, Request};
#[wstd::main]
async fn main() -> Result<(), Box> {
let request = Request::get("https://non-existing-url.example.com")
.body(Body::empty())?;
let _response = Client::new().send(request).await?;
Ok(())
}
```
This will return Exit-code 0 when compiled to wasip2 through the wasi-run WIT-interface, and the error form the application will be throwed away between the wit-interface.
Is this the intended behavior?
For example right now i have to do this to make my "main" applications async
```rust
use std::error::Error;
use wstd::http::{Body, Client, Request};
fn main() {
wstd::runtime::block_on(async move {
if let Err(err) = async_main().await {
eprintln!("{err}");
std::process::exit(1);
}
});
}
async fn async_main() -> Result<(), Box> {
let request = Request::get("https://non-existing-url.example.com").body(Body::empty())?;
let _response = Client::new().send(request).await?;
Ok(())
}
```
コントリビューションガイド
調査の方向性
まず #[wstd::main] の実装を見つけ、Result エラーが wasi-run WIT インターフェースをどのように通過するかを追跡します。issue で説明されている tokio::main パターンとその動作を比較します。失敗した async main がゼロ以外の終了コードを返し、エラーを黙って破棄しなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100