mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Round MCP timeout durations in error messages (#31612)
## Summary MCP operation timeout errors currently print the full debug precision of the remaining timeout budget. That makes a configured 30-second timeout show up as something like `29.999999875s`. This PR rounds the displayed duration to a whole unit, so the error is clean and stable: ```text timed out awaiting tools/list after 30s ``` The timeout behavior itself is unchanged; this only affects the human-facing error text. A regression test covers the reported `tools/list` case.
This commit is contained in:
@@ -228,7 +228,7 @@ where
|
||||
enum ClientOperationError {
|
||||
#[error(transparent)]
|
||||
Service(#[from] rmcp::service::ServiceError),
|
||||
#[error("timed out awaiting {label} after {duration:?}")]
|
||||
#[error("timed out awaiting {label} after {duration:.0?}")]
|
||||
Timeout { label: String, duration: Duration },
|
||||
}
|
||||
|
||||
@@ -1219,6 +1219,16 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn client_operation_timeout_rounds_duration() {
|
||||
let error = ClientOperationError::Timeout {
|
||||
label: "tools/list".to_string(),
|
||||
duration: Duration::from_nanos(29_999_999_875),
|
||||
};
|
||||
|
||||
assert_eq!(error.to_string(), "timed out awaiting tools/list after 30s");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn active_time_timeout_pauses_while_elicitation_is_pending() {
|
||||
let pause_state = ElicitationPauseState::new();
|
||||
|
||||
Reference in New Issue
Block a user