fix(context_engine): prevent retry loop on connection refused errors#2395
Merged
tusharmath merged 3 commits intomainfrom Feb 13, 2026
Merged
fix(context_engine): prevent retry loop on connection refused errors#2395tusharmath merged 3 commits intomainfrom
tusharmath merged 3 commits intomainfrom
Conversation
Comment on lines
+54
to
+56
| let error_msg = format!("{:#}", error); | ||
| if error_msg.contains("Connection refused") || error_msg.contains("tcp connect error") { | ||
| return false; |
Contributor
There was a problem hiding this comment.
Case-sensitive string matching will miss lowercase error messages
The string matching uses .contains("Connection refused") and .contains("tcp connect error") which are case-sensitive. If an error message contains "connection refused" (lowercase) or "TCP connect error" (uppercase), it won't be caught and will proceed to retry.
While OS errors typically use consistent casing, different OS versions, libraries, or error wrapping could produce varied casing.
Fix:
let error_msg = format!("{:#}", error).to_lowercase();
if error_msg.contains("connection refused") || error_msg.contains("tcp connect error") {
return false;
}
Suggested change
| let error_msg = format!("{:#}", error); | |
| if error_msg.contains("Connection refused") || error_msg.contains("tcp connect error") { | |
| return false; | |
| let error_msg = format!("{:#}", error).to_lowercase(); | |
| if error_msg.contains("connection refused") || error_msg.contains("tcp connect error") { | |
| return false; |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves gRPC error handling by detecting connection refused errors and preventing unnecessary retry attempts. This change eliminates retry loops when the semantic search service is offline, providing faster failure feedback and reducing system load from futile connection attempts.
Changes
Core Functionality
should_retry_grpc()to identify service offline scenariosImplementation Details
should_retry_grpc()function incontext_engine.rsto inspect error messages for connection failuresfalseimmediately, skipping retry logicTesting
Added comprehensive test coverage:
Impact
Co-Authored-By: ForgeCode noreply@forgecode.dev