Skip to content
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

Update go version & add verification/testing tools #840

Merged
merged 2 commits into from Aug 26, 2023

Conversation

coreydaley
Copy link
Contributor

Fixes #

Summary of Changes

PS: Make sure your PR includes/updates tests! If you need help with this part, just ask!

@coreydaley coreydaley changed the title Delete .circleci directory Update go version & add verification/testing tools Jul 30, 2023
util.go Outdated Show resolved Hide resolved
conn.go Outdated Show resolved Hide resolved
go.mod Show resolved Hide resolved
@coreydaley coreydaley force-pushed the coreydaley-patch-1 branch 2 times, most recently from 9b696aa to 9bc6e34 Compare August 25, 2023 18:03
@coreydaley coreydaley force-pushed the coreydaley-patch-1 branch 3 times, most recently from 45ec879 to 0058a29 Compare August 25, 2023 18:22
@coreydaley coreydaley enabled auto-merge (squash) August 25, 2023 18:22
@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@8039329). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 0b06b53 differs from pull request most recent head 97ebd5b. Consider uploading reports for the commit 97ebd5b to get more accurate results

@@           Coverage Diff           @@
##             main     #840   +/-   ##
=======================================
  Coverage        ?   66.47%           
=======================================
  Files           ?       11           
  Lines           ?     1596           
  Branches        ?        0           
=======================================
  Hits            ?     1061           
  Misses          ?      424           
  Partials        ?      111           

@coreydaley coreydaley requested review from AlexVulaj, apoorvajagtap and a user August 25, 2023 18:29
LICENSE Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
prepared_test.go Outdated Show resolved Hide resolved
@coreydaley coreydaley merged commit 666c197 into main Aug 26, 2023
11 checks passed
@coreydaley coreydaley deleted the coreydaley-patch-1 branch August 26, 2023 20:01
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling in the package was degraded by changes made in response to lint messages.

@@ -290,7 +294,9 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
}
err = c.SetDeadline(deadline)
if err != nil {
c.Close()
if err := c.Close(); err != nil {
log.Printf("websocket: failed to close network connection: %v", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing to the application's stderr is unfriendly. If you must handle the error in some way, then return nil, errors.Join(err, c.Close()).

This comment applies to other locations where the package writes to the application's stderr.

}

func hideTempErr(err error) error {
if e, ok := err.(net.Error); ok && e.Temporary() {
if e, ok := err.(net.Error); ok {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based the function name, comments at #29 and comments at efd7f76, the purpose of the function is to avoid returning net.Error with Temporary() == true.

In practice, hideTemp error wraps deadline exceeded errors because deadline exceeded is the only temporary error returned from read or write on a connection.

The new code wraps all network errors. Wrapping all errors should be avoided because it can hide useful information from the application.

Either revert back to the original function or remove the function. It's no longer necessary to force Temporary() == false because applications should not call the deprecated Temporary() method.

@@ -981,7 +1002,9 @@ func (c *Conn) handleProtocolError(message string) error {
if len(data) > maxControlFramePayloadSize {
data = data[:maxControlFramePayloadSize]
}
c.WriteControl(CloseMessage, data, time.Now().Add(writeWait))
if err := c.WriteControl(CloseMessage, data, time.Now().Add(writeWait)); err != nil {
return err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The close message error is secondary to the protocol error. Revert to the original or use errors.Join( errors.New("websocket: " + message), c.WriteControl(CloseMessage, data, time.Now().Add(writeWait))).

@@ -998,7 +1021,9 @@ func (c *Conn) handleProtocolError(message string) error {
func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
// Close previous reader, only relevant for decompression.
if c.reader != nil {
c.reader.Close()
if err := c.reader.Close(); err != nil {
log.Printf("websocket: discarding reader close error: %v", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the error instead of writing the application's stderr.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 this comment. or take in a logger and use that.

@@ -1136,7 +1163,9 @@ func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
if h == nil {
h = func(code int, text string) error {
message := FormatCloseMessage(code, "")
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
if err := c.WriteControl(CloseMessage, message, time.Now().Add(writeWait)); err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function h is called before returning a close error to the application. The close error is primary to any error writing the close message. Revert h to the original.

@@ -1161,7 +1190,7 @@ func (c *Conn) SetPingHandler(h func(appData string) error) {
err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
if err == ErrCloseSent {
return nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
} else if _, ok := err.(net.Error); ok {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, the original code returned nil for deadline exceeded errors. The new code returns nil for all network errors. Change to detect deadline exceeded errors only.

@@ -183,7 +184,9 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
}

if brw.Reader.Buffered() > 0 {
netConn.Close()
if err := netConn.Close(); err != nil {
log.Printf("websocket: failed to close network connection: %v", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failure to close network connection is secondary to early write by client. Write to application's stderr is unfriendly. Revert to original or use errors.Join.

netConn.SetDeadline(time.Time{})
if err := netConn.SetDeadline(time.Time{}); err != nil {
if err := netConn.Close(); err != nil {
log.Printf("websocket: failed to close network connection: %v", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deadline error is primary to close error. Either ignore close error or use errors.Join. This comment applies to other calls to SetDeadline in this file.

panic(err)
}
if err := bw.Flush(); err != nil {
log.Printf("websocket: bufioWriterBuffer: Flush: %v", err)
Copy link

@ghost ghost Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flush() will not return an error because writeHook.Write always returns a nil error. Change to panic to indicate that no error is expected here.

nono added a commit to cozy/cozy-stack that referenced this pull request Nov 6, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/gorilla/websocket](https://togithub.com/gorilla/websocket)
| require | patch | `v1.5.0` -> `v1.5.1` |

---

### Release Notes

<details>
<summary>gorilla/websocket (github.com/gorilla/websocket)</summary>

###
[`v1.5.1`](https://togithub.com/gorilla/websocket/releases/tag/v1.5.1)

[Compare
Source](https://togithub.com/gorilla/websocket/compare/v1.5.0...v1.5.1)

#### What's Changed

- Add check for Sec-WebSocket-Key header by
[@&#8203;hirasawayuki](https://togithub.com/hirasawayuki) in
[gorilla/websocket#752
- Changed the method name UnderlyingConn to NetConn by
[@&#8203;JWSong](https://togithub.com/JWSong) in
[gorilla/websocket#773
- remove all versions < 1.16 and add 1.18 by
[@&#8203;ChannyClaus](https://togithub.com/ChannyClaus) in
[gorilla/websocket#793
- Check for and report bad protocol in TLSClientConfig.NextProtos by
[@&#8203;ChannyClaus](https://togithub.com/ChannyClaus) in
[gorilla/websocket#788
- check err before GotConn for trace by
[@&#8203;junnplus](https://togithub.com/junnplus) in
[gorilla/websocket#798
- Update README.md by
[@&#8203;coreydaley](https://togithub.com/coreydaley) in
[gorilla/websocket#839
- Correct way to save memory using write buffer pool and freeing
net.http default buffers by [@&#8203;FMLS](https://togithub.com/FMLS) in
[gorilla/websocket#761
- Update go version & add verification/testing tools by
[@&#8203;coreydaley](https://togithub.com/coreydaley) in
[gorilla/websocket#840
- update golang.org/x/net by
[@&#8203;coreydaley](https://togithub.com/coreydaley) in
[gorilla/websocket#856
- update GitHub workflows by
[@&#8203;coreydaley](https://togithub.com/coreydaley) in
[gorilla/websocket#857

#### New Contributors

- [@&#8203;hirasawayuki](https://togithub.com/hirasawayuki) made their
first contribution in
[gorilla/websocket#752
- [@&#8203;JWSong](https://togithub.com/JWSong) made their first
contribution in
[gorilla/websocket#773
- [@&#8203;ChannyClaus](https://togithub.com/ChannyClaus) made their
first contribution in
[gorilla/websocket#793
- [@&#8203;junnplus](https://togithub.com/junnplus) made their first
contribution in
[gorilla/websocket#798
- [@&#8203;coreydaley](https://togithub.com/coreydaley) made their first
contribution in
[gorilla/websocket#839
- [@&#8203;FMLS](https://togithub.com/FMLS) made their first
contribution in
[gorilla/websocket#761

**Full Changelog**:
gorilla/websocket@v1.5.0...v1.5.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 6am on Monday" in timezone
Europe/Paris, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/cozy/cozy-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->
@rschmied
Copy link

Are the comments made by "Ghost" being addressed / considered? From reading it, there's quite a few things that have changed to the worse, I am in particular bitten by #852 Just wondering...

apoorvajagtap added a commit to apoorvajagtap/gorilla-websocket that referenced this pull request Apr 4, 2024
apoorvajagtap added a commit to apoorvajagtap/gorilla-websocket that referenced this pull request Apr 4, 2024
apoorvajagtap added a commit to apoorvajagtap/gorilla-websocket that referenced this pull request Apr 4, 2024
apoorvajagtap added a commit that referenced this pull request May 1, 2024
@paul-leydier
Copy link

Are the comments made by "Ghost" being addressed / considered? From reading it, there's quite a few things that have changed to the worse, I am in particular bitten by #852 Just wondering...

I'm in the same situation as you, I had to revert the upgrade to 1.5.1 as it printed millions of logs where none where printed before. I saw that #852 and #878 have been merged, but did not make it to a new version as of right now?

@gorilla gorilla deleted a comment from davidnewhall May 4, 2024
algitbot pushed a commit to alpinelinux/build-server-status that referenced this pull request May 5, 2024
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/gorilla/websocket](https://github.com/gorilla/websocket) | require | patch | `v1.5.0` -> `v1.5.1` |

---

### Release Notes

<details>
<summary>gorilla/websocket (github.com/gorilla/websocket)</summary>

### [`v1.5.1`](https://github.com/gorilla/websocket/releases/tag/v1.5.1)

[Compare Source](gorilla/websocket@v1.5.0...v1.5.1)

#### What's Changed

-   Add check for Sec-WebSocket-Key header by [@&#8203;hirasawayuki](https://github.com/hirasawayuki) in gorilla/websocket#752
-   Changed the method name UnderlyingConn to NetConn by [@&#8203;JWSong](https://github.com/JWSong) in gorilla/websocket#773
-   remove all versions < 1.16 and add 1.18 by [@&#8203;ChannyClaus](https://github.com/ChannyClaus) in gorilla/websocket#793
-   Check for and report bad protocol in TLSClientConfig.NextProtos by [@&#8203;ChannyClaus](https://github.com/ChannyClaus) in gorilla/websocket#788
-   check err before GotConn for trace by [@&#8203;junnplus](https://github.com/junnplus) in gorilla/websocket#798
-   Update README.md by [@&#8203;coreydaley](https://github.com/coreydaley) in gorilla/websocket#839
-   Correct way to save memory using write buffer pool and freeing net.http default buffers by [@&#8203;FMLS](https://github.com/FMLS) in gorilla/websocket#761
-   Update go version & add verification/testing tools by [@&#8203;coreydaley](https://github.com/coreydaley) in gorilla/websocket#840
-   update golang.org/x/net by [@&#8203;coreydaley](https://github.com/coreydaley) in gorilla/websocket#856
-   update GitHub workflows by [@&#8203;coreydaley](https://github.com/coreydaley) in gorilla/websocket#857

#### New Contributors

-   [@&#8203;hirasawayuki](https://github.com/hirasawayuki) made their first contribution in gorilla/websocket#752
-   [@&#8203;JWSong](https://github.com/JWSong) made their first contribution in gorilla/websocket#773
-   [@&#8203;ChannyClaus](https://github.com/ChannyClaus) made their first contribution in gorilla/websocket#793
-   [@&#8203;junnplus](https://github.com/junnplus) made their first contribution in gorilla/websocket#798
-   [@&#8203;coreydaley](https://github.com/coreydaley) made their first contribution in gorilla/websocket#839
-   [@&#8203;FMLS](https://github.com/FMLS) made their first contribution in gorilla/websocket#761

**Full Changelog**: gorilla/websocket@v1.5.0...v1.5.1

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

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

See merge request alpine/infra/build-server-status!9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants