fix(server): suppress expected websocket close write errors
This commit is contained in:
@@ -37,6 +37,31 @@ func TestClassifyWSError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldLogWSWriteError(t *testing.T) {
|
||||
tests := []struct {
|
||||
reason string
|
||||
want bool
|
||||
}{
|
||||
{reason: "close_normal", want: false},
|
||||
{reason: "close_going_away", want: false},
|
||||
{reason: "closed", want: false},
|
||||
{reason: "eof", want: false},
|
||||
{reason: "broken_pipe", want: false},
|
||||
{reason: "connection_reset", want: false},
|
||||
{reason: "timeout", want: true},
|
||||
{reason: "close_abnormal", want: true},
|
||||
{reason: "other", want: true},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.reason, func(t *testing.T) {
|
||||
if got := shouldLogWSWriteError(tc.reason); got != tc.want {
|
||||
t.Fatalf("shouldLogWSWriteError(%q)=%v want %v", tc.reason, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWebSocketOutboundQueueTiming(t *testing.T) {
|
||||
sess := &Session{proto: WEBSOCK, send: make(chan any, 2)}
|
||||
payload := []byte("message")
|
||||
|
||||
Reference in New Issue
Block a user