Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Connection refused error shouldn't close the client #872

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions glide-core/src/socket_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,35 +206,28 @@ async fn write_result(
}
Err(ClienUsageError::RedisError(err)) => {
let error_message = err.to_string();
if err.is_connection_refusal() {
log_error("response error", &error_message);
Some(response::response::Value::ClosingError(
error_message.into(),
))
log_warn("received error", error_message.as_str());
log_debug("received error", format!("for callback {}", callback_index));
let mut request_error = response::RequestError::default();
if err.is_connection_dropped() {
request_error.type_ = response::RequestErrorType::Disconnect.into();
request_error.message = format!(
"Received connection error `{error_message}`. Will attempt to reconnect"
)
.into();
} else if err.is_timeout() {
request_error.type_ = response::RequestErrorType::Timeout.into();
request_error.message = error_message.into();
} else {
log_warn("received error", error_message.as_str());
log_debug("received error", format!("for callback {}", callback_index));
let mut request_error = response::RequestError::default();
if err.is_connection_dropped() {
request_error.type_ = response::RequestErrorType::Disconnect.into();
request_error.message = format!(
"Received connection error `{error_message}`. Will attempt to reconnect"
)
.into();
} else if err.is_timeout() {
request_error.type_ = response::RequestErrorType::Timeout.into();
request_error.message = error_message.into();
} else {
request_error.type_ = match err.kind() {
redis::ErrorKind::ExecAbortError => {
response::RequestErrorType::ExecAbort.into()
}
_ => response::RequestErrorType::Unspecified.into(),
};
request_error.message = error_message.into();
}
Some(response::response::Value::RequestError(request_error))
request_error.type_ = match err.kind() {
redis::ErrorKind::ExecAbortError => {
response::RequestErrorType::ExecAbort.into()
}
_ => response::RequestErrorType::Unspecified.into(),
};
request_error.message = error_message.into();
}
Some(response::response::Value::RequestError(request_error))
}
};
write_to_writer(response, writer).await
Expand Down
Loading