bytecodealliance / bytecodealliance/wstd

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

Aperta
#109 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
133
Fork
19
Merge medio
6g 19h
PR unite (30g)
5

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia individuando l’implementazione di #[wstd::main] e seguendo il percorso con cui un errore di Result attraversa l’interfaccia WIT di wasi-run. Confrontane il comportamento con il pattern tokio::main descritto nell’issue. Il lavoro è completato quando un async main che fallisce restituisce un codice di uscita diverso da zero e non scarta silenziosamente l’errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.