bytecodealliance / bytecodealliance/wstd

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

Abierto
#109 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
133
Forks
19
Merge medio
6 d 19 h
PR fusionados (30 d)
5

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza por localizar la implementación de #[wstd::main] y seguir cómo un error de Result atraviesa la interfaz WIT de wasi-run. Compara su comportamiento con el patrón tokio::main descrito en el issue. Se considera terminado cuando un async main que falla devuelve un código de salida distinto de cero y no descarta el error silenciosamente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust
Área
cli
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.