Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 9bc0ed3

Browse files
author
Bjørn
authored
Detect HTTP unexpected EOF errors (#27)
Another attempt on handling io.ErrUnexpectedEOF errors. We can see them in url.Error errors so this change adds those to the error detection logic.
1 parent a22333a commit 9bc0ed3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ func poll(organization org, collector func(org) error) error {
180180
log.Errorf("Collection failed for organization '%s' due timeout", organization.Name)
181181
return nil
182182
}
183+
if httpErr.Err == io.ErrUnexpectedEOF {
184+
log.Errorf("Collection failed for organization '%s' due to unexpected EOF", organization.Name)
185+
return nil
186+
}
183187
}
184188
if err == io.ErrUnexpectedEOF {
185189
log.Errorf("Collection failed for organization '%s' due to unexpected EOF", organization.Name)

main_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ func TestPoll(t *testing.T) {
215215
},
216216
output: nil,
217217
},
218+
{
219+
name: "http unexpected EOF",
220+
collectorErr: &url.Error{
221+
Op: "POST",
222+
URL: "/url",
223+
Err: io.ErrUnexpectedEOF,
224+
},
225+
output: nil,
226+
},
218227
}
219228
for _, tc := range tt {
220229
t.Run(tc.name, func(t *testing.T) {

0 commit comments

Comments
 (0)