GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove noisy printf in NextReader() and beginMessage() by bcreane · Pull Request #878 · gorilla/websocket

Conversation

@bcreane

@bcreane bcreane commented Nov 29, 2023

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Go Version Update
  • Dependency Update

Description

A recent check in causes NextReader() and beginMessage() 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

  • Related Issue #
  • Closes [BUG] Debug messages are printed to log #852

Added/updated tests?

  • Yes
  • No, and this is why: no tests exist to track spurious log entries, so eliding those entries doesn't require a test update
  • I need help with writing tests

Run verifications and test

  • make verify is passing
  • make test is passing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pull-request-size pull-request-size Bot added the size/XS label Nov 29, 2023
@bcreane

bcreane commented Nov 29, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

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:

 // Close previous writer if not already closed by the application. It's
 // probably better to return an error in this situation, but we cannot
 // change this without breaking existing applications.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bcreane bcreane changed the title Remove noisy printf in NextReader() Remove noisy printf in NextReader() and beginMessage() Nov 29, 2023
@ghost

ghost commented Nov 30, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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:

  • Ignore error retuned from r.Close() in flatReadWrapper.Read.

  • Consider returning all errors from the call to c.writer.Close() except errWriteClosed.

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).

warrenguyrain reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Brendan Creane
Remove noisy printf in NextReader()
bcd4e9e
@bcreane
bcreane force-pushed the elide-printf-for-ignorable-errors branch from bd19b38 to bcd4e9e Compare November 30, 2023 17:54
@pull-request-size pull-request-size Bot added size/S and removed size/XS labels Nov 30, 2023
@bcreane

bcreane commented Nov 30, 2023

Copy link
Copy Markdown
Author

@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 c.writer.Close().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost

ghost commented Nov 30, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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().

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DavidJohnSmith
DavidJohnSmith reviewed Dec 7, 2023
View reviewed changes

@DavidJohnSmith DavidJohnSmith left a comment

Copy link
Copy Markdown

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
DavidJohnSmith

This comment was marked as duplicate.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DavidJohnSmith
DavidJohnSmith approved these changes Dec 7, 2023
View reviewed changes
@codecov

codecov Bot commented Dec 11, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (629990d) 69.99% compared to head (bcd4e9e) 70.52%.
Report is 3 commits behind head on main.

Files Patch % Lines
conn.go 75.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexVulaj
AlexVulaj approved these changes Dec 11, 2023
View reviewed changes
@AlexVulaj
AlexVulaj merged commit dcea2f0 into gorilla:main Dec 11, 2023
This was referenced Dec 11, 2023
Do not handle network error in SetCloseHandler() #863
Merged
[BUG] 1.5.1 uses log.Printf #880
Closed
@davidnewhall davidnewhall mentioned this pull request Feb 10, 2024
[BUG] websocket on compress close duplicate #859
Open
1 task done
@paul-leydier paul-leydier mentioned this pull request May 1, 2024
Update go version & add verification/testing tools #840
Merged
@renovate renovate Bot mentioned this pull request Jun 16, 2024
Update go deps livekit/egress#661
Merged
1 task
algitbot pushed a commit to alpinelinux/build-server-status that referenced this pull request Sep 15, 2024
@Ikke
merge: deps: update module github.com/gorilla/websocket to v1.5.3
1d6ff5c
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 [@&#8203;KSDaemon](https://github.com/KSDaemon) in gorilla/websocket#823
-   Update README.md, replace master to main by [@&#8203;mstmdev](https://github.com/mstmdev) in gorilla/websocket#862
-   Use status code constant by [@&#8203;mstmdev](https://github.com/mstmdev) in gorilla/websocket#864
-   conn.go: default close handler should not return ErrCloseSent. by [@&#8203;pnx](https://github.com/pnx) in gorilla/websocket#865
-   fix: replace ioutil.readfile with os.readfile by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#868
-   fix: add comment for the readBufferSize and writeBufferSize by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#869
-   Remove noisy printf in NextReader() and beginMessage() by [@&#8203;bcreane](https://github.com/bcreane) in gorilla/websocket#878
-   docs(echoreadall): fix function echoReadAll comment by [@&#8203;XdpCs](https://github.com/XdpCs) in gorilla/websocket#881
-   make tests parallel by [@&#8203;ninedraft](https://github.com/ninedraft) in gorilla/websocket#872
-   Upgrader.Upgrade: use http.ResposnseController by [@&#8203;ninedraft](https://github.com/ninedraft) in gorilla/websocket#871
-   Do not handle network error in `SetCloseHandler()` by [@&#8203;nak3](https://github.com/nak3) in gorilla/websocket#863
-   perf: reduce timer in write_control by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#879
-   fix: lint example code by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#890
-   feat: format message type by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#889
-   Remove hideTempErr to allow downstream users to check for errors like net.ErrClosed by [@&#8203;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 [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#904
-   Return errors instead of printing to logs by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#897
-   Revert " Update go version & add verification/testing tools ([#&#8203;840](gorilla/websocket#840))" by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#908
-   Fixes broken random value generation by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#926
-   Reverts back to v1.5.0 by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#929

#### New Contributors

-   [@&#8203;KSDaemon](https://github.com/KSDaemon) made their first contribution in gorilla/websocket#823
-   [@&#8203;mstmdev](https://github.com/mstmdev) made their first contribution in gorilla/websocket#862
-   [@&#8203;pnx](https://github.com/pnx) made their first contribution in gorilla/websocket#865
-   [@&#8203;rfyiamcool](https://github.com/rfyiamcool) made their first contribution in gorilla/websocket#868
-   [@&#8203;bcreane](https://github.com/bcreane) made their first contribution in gorilla/websocket#878
-   [@&#8203;XdpCs](https://github.com/XdpCs) made their first contribution in gorilla/websocket#881
-   [@&#8203;ninedraft](https://github.com/ninedraft) made their first contribution in gorilla/websocket#872
-   [@&#8203;nak3](https://github.com/nak3) made their first contribution in gorilla/websocket#863
-   [@&#8203;UnAfraid](https://github.com/UnAfraid) made their first contribution in gorilla/websocket#894
-   [@&#8203;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 [@&#8203;KSDaemon](https://github.com/KSDaemon) in gorilla/websocket#823
-   Update README.md, replace master to main by [@&#8203;mstmdev](https://github.com/mstmdev) in gorilla/websocket#862
-   Use status code constant by [@&#8203;mstmdev](https://github.com/mstmdev) in gorilla/websocket#864
-   conn.go: default close handler should not return ErrCloseSent. by [@&#8203;pnx](https://github.com/pnx) in gorilla/websocket#865
-   fix: replace ioutil.readfile with os.readfile by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#868
-   fix: add comment for the readBufferSize and writeBufferSize by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#869
-   Remove noisy printf in NextReader() and beginMessage() by [@&#8203;bcreane](https://github.com/bcreane) in gorilla/websocket#878
-   docs(echoreadall): fix function echoReadAll comment by [@&#8203;XdpCs](https://github.com/XdpCs) in gorilla/websocket#881
-   make tests parallel by [@&#8203;ninedraft](https://github.com/ninedraft) in gorilla/websocket#872
-   Upgrader.Upgrade: use http.ResposnseController by [@&#8203;ninedraft](https://github.com/ninedraft) in gorilla/websocket#871
-   Do not handle network error in `SetCloseHandler()` by [@&#8203;nak3](https://github.com/nak3) in gorilla/websocket#863
-   perf: reduce timer in write_control by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#879
-   fix: lint example code by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#890
-   feat: format message type by [@&#8203;rfyiamcool](https://github.com/rfyiamcool) in gorilla/websocket#889
-   Remove hideTempErr to allow downstream users to check for errors like net.ErrClosed by [@&#8203;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 [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#904
-   Return errors instead of printing to logs by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#897
-   Revert " Update go version & add verification/testing tools ([#&#8203;840](gorilla/websocket#840))" by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#908
-   Fixes broken random value generation by [@&#8203;apoorvajagtap](https://github.com/apoorvajagtap) in gorilla/websocket#926

#### New Contributors

-   [@&#8203;KSDaemon](https://github.com/KSDaemon) made their first contribution in gorilla/websocket#823
-   [@&#8203;mstmdev](https://github.com/mstmdev) made their first contribution in gorilla/websocket#862
-   [@&#8203;pnx](https://github.com/pnx) made their first contribution in gorilla/websocket#865
-   [@&#8203;rfyiamcool](https://github.com/rfyiamcool) made their first contribution in gorilla/websocket#868
-   [@&#8203;bcreane](https://github.com/bcreane) made their first contribution in gorilla/websocket#878
-   [@&#8203;XdpCs](https://github.com/XdpCs) made their first contribution in gorilla/websocket#881
-   [@&#8203;ninedraft](https://github.com/ninedraft) made their first contribution in gorilla/websocket#872
-   [@&#8203;nak3](https://github.com/nak3) made their first contribution in gorilla/websocket#863
-   [@&#8203;UnAfraid](https://github.com/UnAfraid) made their first contribution in gorilla/websocket#894
-   [@&#8203;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

---

&nbsp;
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yODYuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQxOS4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

See merge request alpine/infra/build-server-status!14
jholdstock added a commit to jholdstock/go-binance that referenced this pull request Jan 23, 2025
@jholdstock
Update gorilla/websocket to 1.5.3.
fecde50
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.
@jholdstock jholdstock mentioned this pull request Jan 23, 2025
Update gorilla/websocket to 1.5.3. ccxt/go-binance#658
Merged
adshao pushed a commit to ccxt/go-binance that referenced this pull request Jan 27, 2025
@jholdstock
Update gorilla/websocket to 1.5.3. (#658)
7b9db0e
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexVulaj AlexVulaj AlexVulaj approved these changes
+1 more reviewer
@DavidJohnSmith DavidJohnSmith DavidJohnSmith approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size/S

Projects

Gorilla Web Toolkit
Status: ✅ Done

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] Debug messages are printed to log

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bcreane @DavidJohnSmith @AlexVulaj
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.