bytecodealliance / bytecodealliance/wstd

wstd::main doesn't set exit code on failure

Đang mở
#109 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
133
Fork
19
Merge trung bình
6 ngày 19 giờ
Pull request đã merge (30 ngày)
5

Mô tả

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(())
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách xác định phần triển khai của #[wstd::main] và theo dõi cách một lỗi Result đi qua giao diện WIT của wasi-run. So sánh hành vi của nó với mẫu tokio::main được mô tả trong issue. Hoàn tất khi một async main bị lỗi trả về mã thoát khác 0 và không âm thầm loại bỏ lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.