Skip to content

fix: preserve SSH forwarding half-close semantics - #34

Merged
skevetter merged 3 commits into
mainfrom
ragged-ladybug
Sep 11, 2026
Merged

fix: preserve SSH forwarding half-close semantics#34
skevetter merged 3 commits into
mainfrom
ragged-ladybug

Conversation

@skevetter

@skevetter skevetter commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve bidirectional forwarding after normal EOF by half-closing only the destination write side
  • fully close both endpoints on context cancellation or copy/half-close errors
  • add TCP regression coverage for request/response half-close behavior

Verification

  • go vet ./...
  • go test ./...
  • go test -race ./...
  • git diff --check

CodeRabbit local review completed; its read-deadline finding was addressed in the follow-up test commit.

Summary by CodeRabbit

  • Bug Fixes
    • Improved bidirectional TCP connection handling during half-close and EOF scenarios.
    • Connections now remain available for the opposite direction until both data transfers complete.
    • Improved cleanup when transfers are canceled or encounter errors.
  • Tests
    • Added coverage for bidirectional transfers, half-close propagation, EOF handling, and completion behavior.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ae249bed-93cf-41f7-bc6f-7e609cf0d3b9

📥 Commits

Reviewing files that changed from the base of the PR and between 4a5658e and a680563.

📒 Files selected for processing (2)
  • tcpip.go
  • tcpip_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

bicopy now coordinates two directional copies that preserve TCP half-close behavior. The tests create loopback TCP pairs and verify bidirectional data transfer, EOF propagation, and completion.

Changes

TCP half-close forwarding

Layer / File(s) Summary
Bicopy half-close coordination
tcpip.go
bicopy runs two copyAndHalfClose operations, handles cancellation and copy errors, and closes both connections after both directions finish. CloseWrite errors from io.EOF are treated as success.
Half-close integration validation
tcpip_test.go
The tests create loopback TCP connection pairs and verify bidirectional transfer, half-close propagation, EOF handling, and bicopy completion.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant bicopy
  participant copyAndHalfClose
  participant TCPConnections
  bicopy->>copyAndHalfClose: Start two directional copies
  copyAndHalfClose->>TCPConnections: Copy data
  copyAndHalfClose->>TCPConnections: CloseWrite after EOF
  copyAndHalfClose-->>bicopy: Return copyResult
  bicopy->>TCPConnections: Close both connections after completion or error
Loading

Merge Risk: ⚪ Minimal · up to a6805

The forwarding change has regression coverage for request/response half-closes and no actionable current-head risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving SSH forwarding half-close semantics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch ragged-ladybug

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.

@skevetter
skevetter marked this pull request as ready for review September 11, 2026 06:25
@skevetter
skevetter merged commit 70992bf into main Sep 11, 2026
6 checks passed
@skevetter
skevetter deleted the ragged-ladybug branch September 11, 2026 06:30
@devsy-app devsy-app Bot mentioned this pull request Sep 11, 2026
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.

1 participant