fix: Check for stderr error in receive() (#2905)

This commit is contained in:
Jack Amadeo
2025-06-13 14:43:45 -04:00
committed by GitHub
parent a7ad73197d
commit fe694c228d
4 changed files with 38 additions and 7 deletions

View File

@@ -22,6 +22,17 @@ async fn main() -> Result<()> {
test_transport(sse_transport().await?).await?;
test_transport(stdio_transport().await?).await?;
// Test broken transport
match test_transport(broken_stdio_transport().await?).await {
Ok(_) => assert!(false, "Expected an error but got success"),
Err(e) => {
assert!(e
.to_string()
.contains("error: package(s) `thispackagedoesnotexist` not found in workspace"));
println!("Expected error occurred: {e}");
}
}
Ok(())
}
@@ -52,6 +63,17 @@ async fn stdio_transport() -> Result<StdioTransport> {
))
}
async fn broken_stdio_transport() -> Result<StdioTransport> {
Ok(StdioTransport::new(
"cargo",
vec!["run", "-p", "thispackagedoesnotexist"]
.into_iter()
.map(|s| s.to_string())
.collect(),
HashMap::new(),
))
}
async fn test_transport<T>(transport: T) -> Result<()>
where
T: Transport + Send + 'static,