bytecodealliance / bytecodealliance/wstd
wstd::main doesn't set exit code on failure
还没有人认领这个 Issue。
- 主要语言
- Rust
- 星标
- 135
- 派生
- 19
- 平均合并
- 6 天 19 小时
- 30 天内合并 PR
- 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(())
}
```
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 #[wstd::main] 的实现,并跟踪 Result 错误如何穿过 wasi-run WIT 接口。将其行为与 issue 中描述的 tokio::main 模式进行比较。当失败的 async main 返回非零退出码且不会静默丢弃错误时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100