fix: client robustness improvements (v1.0.3)#5
Merged
Conversation
- Add 30s AbortSignal timeout to all API requests in client.request() - Gracefully handle non-JSON error responses instead of throwing SyntaxError - Show both terraform/terragrunt options in remediation code block - Bump version to 1.0.3 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Three patch-level fixes to improve reliability and correctness.
1. Request timeout (
client.ts)All API requests now time out after 30 seconds via
AbortSignal.timeout(30_000). Previously a slow or unresponsive DriftHound API would stall an MCP tool call indefinitely.ping()already had a 5s timeout — this brings the same safety to all requests.2. Graceful non-JSON error responses (
client.ts)If the API returns a non-JSON body on a non-2xx response (e.g. a
502from a proxy returning HTML),response.json()was throwing aSyntaxErrorthat masked the real HTTP error. Now falls back toHTTP <status>: <statusText>.3. Remediation hint no longer assumes Terragrunt (
get-environment-info.ts)The remediation code block hardcoded
terragrunt plan. Since the API response doesn't indicate which tool a project uses, it now showsterraform plan # or: terragrunt plan.Test plan
npm test) ✅ 49/49DRIFTHOUND_API_URLat a non-responsive host — tool call should fail after ~30s with a timeout error instead of hanging🤖 Generated with Claude Code