fix(client): bump HTTP timeout 1.5s → 5s, REFUSE_TIMEOUT_MS override#27
Open
gok03 wants to merge 2 commits into
Open
fix(client): bump HTTP timeout 1.5s → 5s, REFUSE_TIMEOUT_MS override#27gok03 wants to merge 2 commits into
gok03 wants to merge 2 commits into
Conversation
…rride The hardcoded 1.5s HTTP timeout was too tight for real-world networks: hotel Wi-Fi, long-RTT links, or any path where TLS handshake + first byte stretches past 1.5s would see every gate call fail open with a "server: unreachable" line in stderr. Bump the default to 5s (still a clearly-interactive feel — a user typing `pip install foo` won't notice an extra ~half-second on a slow network, but will appreciate not seeing the gate fail) and expose a REFUSE_TIMEOUT_MS env var for users who want to tune it further. README documents both the new env var and REFUSE_NO_GATE (which already existed in shim/run.go but wasn't documented).
Measured mcp.refuse.dev latency: first request after idle is ~4.6s (scale-from-zero cold start), then 0.2–0.4s warm. A 5s default left only ~0.4s margin over the cold start; bump to 8s so the first install after an idle period doesn't fail open with a "server: unreachable" warning. Still fails reasonably fast when the server is genuinely down, and REFUSE_TIMEOUT_MS overrides for anyone who wants tighter/looser.
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.
Symptom
Users on slow / high-latency networks see every gate call fail with:
```
refuse: server: unreachable: Post "https://mcp.refuse.dev/api/v1/check/batch\":
context deadline exceeded (Client.Timeout exceeded while awaiting headers)
```
even though the server is healthy (`/healthz` returns 200 in ~600ms when curl'd from a fast network).
Root cause
`internal/server/client.go` hardcoded `Timeout: 1500 * time.Millisecond`. Any RTT > 1.5s (hotel Wi-Fi, cellular, cold-start TLS handshake) trips it.
Fix
Test plan