-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Remove noisy printf in NextReader() and beginMessage() #878
Remove noisy printf in NextReader() and beginMessage() #878
Conversation
I realize that ignoring these errors may not be ideal, however there's a note from an earlier contributor that points out that returning these errors is not feasible w/o breaking the current API contract:
|
Regarding c.reader.Close() The call invokes messageReader.Close or flateReadWrapper.Close. messageReader.Close always returns nil. flatReadWrapper.Close returns io.ErrClosedPipe when closed previously. This error is safe to ignore. If the read wrapper is not closed, then flatReadWrapper.Close calls the flat reader Close method. The error returned from the flat Reader Close method is safe to ignore because that error would have been handled in a previous call to Read. Summary: it's safe to ignore the error returned from c.reader.Close(). There is another call to flatReadWrapper.Close here. That code should also ignore the returned error. Regarding c.writer.Close() The comment says that returning the error will break existing applications. Prior to the addition of that comment, the package returned the error from cleaning up the previous message. I believe the problem is that flatWriteWrapper.Close returns an error when called more than once. That error should be ignored, but now all errors are ignored. Perhaps that specific error should be ignored and all other errors should be returned. Summary:
Edit: The c.writer.Close error was ignored for years. There's no indication in the issues that this caused any problems. The safe course of action is to remove the the calls to log.Printf (the two calls this PR and the call in flatReadWrapper.Read). |
bd19b38
to
bcd4e9e
Compare
@pennystevens thank you for the thoughtful comments - I learned a bit more about the internals as a result of you leading me through the various interfaces and their behaviors. I elected to go with the "safe" approach which is to continue to ignore the errors returned via |
More on c.writer.Close(): The first write error on the connection is saved in Conn.writeErr. If c.writer.Close() returned an error because write to the connection failed, then the error is saved in Conn.writerErr. Conn.beginMessage returns that saved error. It is therefore safe to ignore the error returned from c.writer.Close(). |
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 also find this problem,thanks for your commit
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #878 +/- ##
==========================================
+ Coverage 69.99% 70.52% +0.52%
==========================================
Files 11 11
Lines 1593 1591 -2
==========================================
+ Hits 1115 1122 +7
+ Misses 364 358 -6
+ Partials 114 111 -3 ☔ View full report in Codecov by Sentry. |
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/gorilla/websocket](https://github.com/gorilla/websocket) | require | patch | `v1.5.1` -> `v1.5.3` | --- ### Release Notes <details> <summary>gorilla/websocket (github.com/gorilla/websocket)</summary> ### [`v1.5.3`](https://github.com/gorilla/websocket/releases/tag/v1.5.3) [Compare Source](gorilla/websocket@v1.5.2...v1.5.3) #### Important change This reverts the websockets package back to gorilla/websocket@931041c #### What's Changed - Fixes subprotocol selection (aling with rfc6455) by [@​KSDaemon](https://github.com/KSDaemon) in gorilla/websocket#823 - Update README.md, replace master to main by [@​mstmdev](https://github.com/mstmdev) in gorilla/websocket#862 - Use status code constant by [@​mstmdev](https://github.com/mstmdev) in gorilla/websocket#864 - conn.go: default close handler should not return ErrCloseSent. by [@​pnx](https://github.com/pnx) in gorilla/websocket#865 - fix: replace ioutil.readfile with os.readfile by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#868 - fix: add comment for the readBufferSize and writeBufferSize by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#869 - Remove noisy printf in NextReader() and beginMessage() by [@​bcreane](https://github.com/bcreane) in gorilla/websocket#878 - docs(echoreadall): fix function echoReadAll comment by [@​XdpCs](https://github.com/XdpCs) in gorilla/websocket#881 - make tests parallel by [@​ninedraft](https://github.com/ninedraft) in gorilla/websocket#872 - Upgrader.Upgrade: use http.ResposnseController by [@​ninedraft](https://github.com/ninedraft) in gorilla/websocket#871 - Do not handle network error in `SetCloseHandler()` by [@​nak3](https://github.com/nak3) in gorilla/websocket#863 - perf: reduce timer in write_control by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#879 - fix: lint example code by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#890 - feat: format message type by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#889 - Remove hideTempErr to allow downstream users to check for errors like net.ErrClosed by [@​UnAfraid](https://github.com/UnAfraid) in gorilla/websocket#894 - Do not timeout when WriteControl deadline is zero in gorilla/websocket#898 - Excludes errchecks linter by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#904 - Return errors instead of printing to logs by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#897 - Revert " Update go version & add verification/testing tools ([#​840](gorilla/websocket#840))" by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#908 - Fixes broken random value generation by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#926 - Reverts back to v1.5.0 by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#929 #### New Contributors - [@​KSDaemon](https://github.com/KSDaemon) made their first contribution in gorilla/websocket#823 - [@​mstmdev](https://github.com/mstmdev) made their first contribution in gorilla/websocket#862 - [@​pnx](https://github.com/pnx) made their first contribution in gorilla/websocket#865 - [@​rfyiamcool](https://github.com/rfyiamcool) made their first contribution in gorilla/websocket#868 - [@​bcreane](https://github.com/bcreane) made their first contribution in gorilla/websocket#878 - [@​XdpCs](https://github.com/XdpCs) made their first contribution in gorilla/websocket#881 - [@​ninedraft](https://github.com/ninedraft) made their first contribution in gorilla/websocket#872 - [@​nak3](https://github.com/nak3) made their first contribution in gorilla/websocket#863 - [@​UnAfraid](https://github.com/UnAfraid) made their first contribution in gorilla/websocket#894 - [@​apoorvajagtap](https://github.com/apoorvajagtap) made their first contribution in gorilla/websocket#904 **Full Changelog**: gorilla/websocket@v1.5.1...v1.5.3 ### [`v1.5.2`](https://github.com/gorilla/websocket/releases/tag/v1.5.2) [Compare Source](gorilla/websocket@v1.5.1...v1.5.2) #### What's Changed - Fixes subprotocol selection (aling with rfc6455) by [@​KSDaemon](https://github.com/KSDaemon) in gorilla/websocket#823 - Update README.md, replace master to main by [@​mstmdev](https://github.com/mstmdev) in gorilla/websocket#862 - Use status code constant by [@​mstmdev](https://github.com/mstmdev) in gorilla/websocket#864 - conn.go: default close handler should not return ErrCloseSent. by [@​pnx](https://github.com/pnx) in gorilla/websocket#865 - fix: replace ioutil.readfile with os.readfile by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#868 - fix: add comment for the readBufferSize and writeBufferSize by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#869 - Remove noisy printf in NextReader() and beginMessage() by [@​bcreane](https://github.com/bcreane) in gorilla/websocket#878 - docs(echoreadall): fix function echoReadAll comment by [@​XdpCs](https://github.com/XdpCs) in gorilla/websocket#881 - make tests parallel by [@​ninedraft](https://github.com/ninedraft) in gorilla/websocket#872 - Upgrader.Upgrade: use http.ResposnseController by [@​ninedraft](https://github.com/ninedraft) in gorilla/websocket#871 - Do not handle network error in `SetCloseHandler()` by [@​nak3](https://github.com/nak3) in gorilla/websocket#863 - perf: reduce timer in write_control by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#879 - fix: lint example code by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#890 - feat: format message type by [@​rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#889 - Remove hideTempErr to allow downstream users to check for errors like net.ErrClosed by [@​UnAfraid](https://github.com/UnAfraid) in gorilla/websocket#894 - Do not timeout when WriteControl deadline is zero in gorilla/websocket#898 - Excludes errchecks linter by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#904 - Return errors instead of printing to logs by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#897 - Revert " Update go version & add verification/testing tools ([#​840](gorilla/websocket#840))" by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#908 - Fixes broken random value generation by [@​apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#926 #### New Contributors - [@​KSDaemon](https://github.com/KSDaemon) made their first contribution in gorilla/websocket#823 - [@​mstmdev](https://github.com/mstmdev) made their first contribution in gorilla/websocket#862 - [@​pnx](https://github.com/pnx) made their first contribution in gorilla/websocket#865 - [@​rfyiamcool](https://github.com/rfyiamcool) made their first contribution in gorilla/websocket#868 - [@​bcreane](https://github.com/bcreane) made their first contribution in gorilla/websocket#878 - [@​XdpCs](https://github.com/XdpCs) made their first contribution in gorilla/websocket#881 - [@​ninedraft](https://github.com/ninedraft) made their first contribution in gorilla/websocket#872 - [@​nak3](https://github.com/nak3) made their first contribution in gorilla/websocket#863 - [@​UnAfraid](https://github.com/UnAfraid) made their first contribution in gorilla/websocket#894 - [@​apoorvajagtap](https://github.com/apoorvajagtap) made their first contribution in gorilla/websocket#904 **Full Changelog**: gorilla/websocket@v1.5.1...v1.5.2 </details> --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yODYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxOS4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> See merge request alpine/infra/build-server-status!14
This fixes an issue where the websocket library was spamming stdout with unimportant messages. For example, the following message would be printed repeatedly while using WsDepthServe: ``` websocket: discarding reader close error: io: read/write on closed pipe ``` The issue was fixed in gorilla/websocket#878.
This fixes an issue where the websocket library was spamming stdout with unimportant messages. For example, the following message would be printed repeatedly while using WsDepthServe: ``` websocket: discarding reader close error: io: read/write on closed pipe ``` The issue was fixed in gorilla/websocket#878.
What type of PR is this? (check all applicable)
Description
A recent check in causes
NextReader()
andbeginMessage()
to emit noisy, non-actionable messages that fill up application logs. This PR restores the previous approach of ignoring reader/writer close errors. This should address #852.Related Tickets & Documents
Added/updated tests?
Run verifications and test
make verify
is passingmake test
is passing