-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-arrange error handling a bit #529
Conversation
This isn't quite right. I'll fix it in the morning. |
If we did throw an error and tried to close the connection, there's no reason to try to do so again during the finally block. Also, if we are in the error block, close(io) has quite a high chance for failing, so wrap it in try to suppress such errors and instead rethrow the original error.
Closing the connection is a courtesy for the remote end, and one that is usually repayed by having the remote slam shut, which causes us to error. Don't propogate those errors to the user - instead only propagate errors from the read and the write end.
I've pushed another commit here that tries to propagate the correct error to the user. Before this, e.g. the AWS retry layer would get very mad at the random errors thrown by these close functions and just retry a request that failed for good reason. |
return r | ||
catch e | ||
@debug 1 "❗️ ConnectionLayer $e. Closing: $io" | ||
try; close(io); catch; end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is why we say close
shouldn't error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...
If we did throw an error and tried to close the connection,
there's no reason to try to do so again during the finally block.
Also, if we are in the error block, close(io) has quite a high chance
for failing, so wrap it in try to suppress such errors and instead
rethrow the original error.