-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Issue-1103 - Fixing broken pipe errors #1170
Conversation
Thanks for this contribution, please fix the lint errors and merge conflicts |
Hey @JyotinderSingh! Sure, i would resolve the merge conflicts, however I believe the linting errors existed even before I tried to make any change as they are in files different to the one I had made changes to, I don't want to break the codebase |
724ec50
to
fecbd7f
Compare
Hey @JyotinderSingh! I think the code should be good for review now , thank you for the help |
There's merge conflicts again, I assume a PR got merged, I'll fix it |
5a70778
to
f60e85b
Compare
I have rebased the branch again to follow the linear path for the new master branch with merged PRs. |
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.
Thanks for these changes. Left a couple of comments.
internal/server/websocketServer.go
Outdated
if !websocket.IsCloseError(err, errs...) { | ||
slog.Warn("failed to read message from client", slog.Any("error", err)) | ||
if websocket.IsCloseError(err, errs...) { | ||
slog.Info("Gracefully Exited") |
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.
This doesn't need to be logged.
internal/server/websocketServer.go
Outdated
} | ||
|
||
if messageType == websocket.CloseMessage { | ||
slog.Info("graceful shutdown...") |
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.
This does not need to be logged.
internal/server/websocketServer.go
Outdated
_ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)")) | ||
closeErr := conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "close 1000 (normal)")) | ||
if closeErr != nil { | ||
slog.Warn("Error during closing handshake", slog.Any("error", closeErr)) |
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.
Make this a debug log.
- imports changed - outdented the code from the else block due to break statement in if block - removed extra blank line for consistent formatting
I have included your suggestions in the codebase, please let me know if you need any other changes as well Thank you! |
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.
LGTM. Thanks for this contribution!
The identification of broken pipe is only when there is an abrupt exit, so what I saw in the codebase was there are only a couple of places that deal with the closure of WebSocket connections, most of them were only handling the case where the user exited irrespective if it was gracefully or abruptly, so I modified and added some sections for the same
closing_handshake
, it wasn't checking if the closeValue had an error, indicating that there was an error while closing the connection, so I added a check for the sameerrs
category, it means that there is a graceful exit, otherwise, the exit was due to another error, so I have added the check for the sameWriteResponseWithRetries
you have a case where the function returns thesyscall.EPIPE
error, this function is utilized in WebSocketHandler function, so I have added the check for the sameThose were all the that i found were capable of returning broken pipe errors, i have provided the segregated messages for the same, please do let me know if any other changes or features are needed
Fixes #1103
Thank you!