Open markvai opened 8 months ago
We got this error when using the client:
unexpected EOF: file already closed
We don't expect to see file already closed errors.
file already closed
This is sporadic and can happen when reading from the http response body after a valid response status was received.
The root cause here it's possible that an error is returned while reading the response body, like here: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/jira.go#L249-L250
So while decoding there is a network error and the read fails, not the body is closed on defer.
Than the error is passed to: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/issue.go#L1084
And there, it is expected that the body was not closed/read already, so it tries to read again from the body: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/error.go#L25-L26
As a result we get a confusing error.
What happened?
We got this error when using the client:
What did you expect to happen?
We don't expect to see
file already closed
errors.How can we reproduce it (as minimally and precisely as possible)?
This is sporadic and can happen when reading from the http response body after a valid response status was received.
The root cause here it's possible that an error is returned while reading the response body, like here: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/jira.go#L249-L250
So while decoding there is a network error and the read fails, not the body is closed on defer.
Than the error is passed to: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/issue.go#L1084
And there, it is expected that the body was not closed/read already, so it tries to read again from the body: https://github.com/andygrunwald/go-jira/blob/50d59fe116d6b0d7156e4129be4963b910c60c11/cloud/error.go#L25-L26
As a result we get a confusing error.