Skip to content

Replace string matching with syscall error checking for connection resets#22

Merged
gerhardgruber merged 4 commits intogg/connection_reset_status_checkfrom
copilot/sub-pr-21
Nov 25, 2025
Merged

Replace string matching with syscall error checking for connection resets#22
gerhardgruber merged 4 commits intogg/connection_reset_status_checkfrom
copilot/sub-pr-21

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

The connection reset detection relied on string matching against platform-specific error messages ("connection was forcibly closed by the remote host" on Windows, "connection reset by peer" on Unix). This is fragile and breaks across Go versions or platforms.

Changes:

  • Check underlying syscall error type using errors.Is(opErr.Err, syscall.ECONNRESET) instead of string matching
  • Remove strings import, add syscall import
  • Platform-agnostic: handles ECONNRESET (Unix) and WSAECONNRESET (Windows) automatically

Before:

if strings.Contains(opErr.Error(), "connection was forcibly closed by the remote host") || 
   strings.Contains(opErr.Error(), "connection reset by peer") {
    logDebugf("Ignoring forceful connection closure by server")
    break
}

After:

if errors.Is(opErr.Err, syscall.ECONNRESET) {
    logDebugf("Ignoring forceful connection closure by server")
    break
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hq.documatrix.com
    • Triggering command: /tmp/go-build4141503950/b001/go-lprlib.test /tmp/go-build4141503950/b001/go-lprlib.test -test.testlogfile=/tmp/go-build4141503950/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build2398867556/b001/go-lprlib.test /tmp/go-build2398867556/b001/go-lprlib.test -test.testlogfile=/tmp/go-build2398867556/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true -test.run=TestDNS (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update connection reset status check implementation Replace string matching with syscall error checking for connection resets Nov 25, 2025
Copilot AI requested a review from gerhardgruber November 25, 2025 11:42
Copilot AI and others added 3 commits November 25, 2025 12:53
…on resets

Co-authored-by: gerhardgruber <1944892+gerhardgruber@users.noreply.github.com>
Co-authored-by: gerhardgruber <1944892+gerhardgruber@users.noreply.github.com>
@gerhardgruber gerhardgruber marked this pull request as ready for review November 25, 2025 15:31
@gerhardgruber gerhardgruber merged commit b6bff46 into gg/connection_reset_status_check Nov 25, 2025
2 checks passed
@gerhardgruber gerhardgruber deleted the copilot/sub-pr-21 branch November 25, 2025 15:31
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.

2 participants