Skip to content

fix: raise the proxy and tunnel read and write timeouts to 120s - #450

Merged
alnr merged 1 commit into
masterfrom
fix/302-proxy-timeouts
Jul 29, 2026
Merged

fix: raise the proxy and tunnel read and write timeouts to 120s#450
alnr merged 1 commit into
masterfrom
fix/302-proxy-timeouts

Conversation

@alnr

@alnr alnr commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #302

graceful.WithDefaults applies a 5s read and 10s write timeout to the proxy and tunnel server. Any exchange slower than that was cut off mid-flight, so the client got an empty reply with no status and no error:

$ curl localhost:4000/long -v
* Empty reply from server
curl: (52) Empty reply from server

The reporter's observed 9.5s-works / 10.5s-fails boundary matches the 10s write deadline exactly. The read timeout caused the same silent truncation for slow or large request bodies. The upstream here is the developer's own application and may legitimately take longer than either.

Raises both to 120s. graceful.WithDefaults only fills in zero values, so non-zero values set on the server pass through untouched.

Note that ReadHeaderTimeout stays at graceful's 5s, since net/http prefers it over ReadTimeout for the header phase — request headers still have to arrive promptly, while the body now gets the full 120s.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JYzGVwAKQ4ormxRHZg1eDu

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The proxy adds read and write timeout flags, validates and applies them when creating HTTP servers, adjusts header deadlines, and routes reverse-proxy server creation through the new helper. Response-writer unwrapping and tests cover streaming, hijacking, and timeout behavior.

Changes

Proxy timeout and response handling

Layer / File(s) Summary
Server timeout configuration
cmd/cloudx/proxy/helpers.go, cmd/cloudx/proxy/helpers_test.go
Adds timeout flags and config fields, validates timeout values, applies HTTP server deadlines, and tests default, configured, invalid, and write-timeout behavior.
Reverse proxy writer integration
cmd/cloudx/proxy/helpers.go, cmd/cloudx/proxy/helpers_test.go
Routes reverse-proxy server creation through newServer, adds Unwrap() to responseStatusCatcher, and tests Flush, Hijack, and status forwarding.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant registerConfigFlags
  participant newServer
  participant http.Server
  participant ReverseProxy
  CLI->>registerConfigFlags: configure read-timeout and write-timeout
  registerConfigFlags->>newServer: pass timeout durations
  newServer->>http.Server: apply read, header, and write deadlines
  ReverseProxy->>http.Server: serve proxied request
  http.Server-->>ReverseProxy: enforce configured response deadline
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It explains the bug and fix, but it doesn't follow the required template sections or include the checklist and further comments. Add the template headings for big picture, related issue/design doc, checklist, and further comments, and fill the required checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #302 by removing the default deadline that caused empty proxy responses and by adding the requested timeout controls.
Out of Scope Changes check ✅ Passed The extra Unwrap fix and tests are directly related to proxy response handling and streaming behavior, so they are not out of scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title matches the main change: increasing proxy/tunnel read and write timeouts.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/302-proxy-timeouts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alnr
alnr force-pushed the fix/302-proxy-timeouts branch from d7745c3 to 35d63ab Compare July 29, 2026 13:34
@alnr alnr changed the title fix: do not truncate proxy/tunnel responses after 10 seconds fix: raise the proxy and tunnel write timeout to 120s Jul 29, 2026
graceful.WithDefaults applies a 5s read and 10s write timeout, which cut
slower exchanges off mid-flight and left the client with an empty reply
rather than an error. The upstream is the developer's own application
and may legitimately take longer.

Closes #302

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JYzGVwAKQ4ormxRHZg1eDu
@alnr
alnr force-pushed the fix/302-proxy-timeouts branch from 35d63ab to b4740f3 Compare July 29, 2026 13:37
@alnr alnr changed the title fix: raise the proxy and tunnel write timeout to 120s fix: raise the proxy and tunnel read and write timeouts to 120s Jul 29, 2026
@alnr
alnr merged commit 95d2e58 into master Jul 29, 2026
18 checks passed
@alnr
alnr deleted the fix/302-proxy-timeouts branch July 29, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy returns empty response for long requests

2 participants