language_models: Remove unnecessary LM Studio connection refused log (#37277)
In zed logs you can see these logs of lmstudio connection refused. Currently zed connects to lmstudio by default as there is no credential mechanism to check if the user has enabled lmstudio previously or not like we do with other providers using api keys. This pr removes the below annoying log and makes the zed logs less polluted. ``` 2025-09-01T02:11:33+05:30 ERROR [language_models] Other(error sending request for url (http://localhost:1234/api/v0/models) Caused by: 0: client error (Connect) 1: tcp connect error: Connection refused (os error 61) 2: Connection refused (os error 61)) ``` Release Notes: - N/A --------- Signed-off-by: Umesh Yadav <git@umesh.dev>
This commit is contained in:
@@ -111,7 +111,30 @@ impl State {
|
||||
}
|
||||
|
||||
let fetch_models_task = self.fetch_models(cx);
|
||||
cx.spawn(async move |_this, _cx| Ok(fetch_models_task.await?))
|
||||
cx.spawn(async move |_this, _cx| {
|
||||
match fetch_models_task.await {
|
||||
Ok(()) => Ok(()),
|
||||
Err(err) => {
|
||||
// If any cause in the error chain is an std::io::Error with
|
||||
// ErrorKind::ConnectionRefused, treat this as "credentials not found"
|
||||
// (i.e. LM Studio not running).
|
||||
let mut connection_refused = false;
|
||||
for cause in err.chain() {
|
||||
if let Some(io_err) = cause.downcast_ref::<std::io::Error>() {
|
||||
if io_err.kind() == std::io::ErrorKind::ConnectionRefused {
|
||||
connection_refused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if connection_refused {
|
||||
Err(AuthenticateError::ConnectionRefused)
|
||||
} else {
|
||||
Err(AuthenticateError::Other(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user