diff --git a/crates/wasi-common/src/ctx.rs b/crates/wasi-common/src/ctx.rs index 5f3c798fa1..20a9ef7064 100644 --- a/crates/wasi-common/src/ctx.rs +++ b/crates/wasi-common/src/ctx.rs @@ -64,6 +64,17 @@ pub struct WasiCtxBuilder(WasiCtx); impl WasiCtxBuilder { pub fn build(self) -> Result { + use crate::file::TableFileExt; + let t = self.0.table(); + for (fd, name) in ["stdin", "stdout", "stderr"].iter().enumerate() { + if t.get_file(fd as u32).is_err() { + return Err(anyhow::anyhow!( + "Cannot build WasiCtx: Missing required file `{}`", + name + )); + } + } + drop(t); Ok(self.0) }