Skip to content

Commit

Permalink
Fixes internal server error when dialing websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Oct 1, 2024
1 parent 1ad9c3b commit 15d05d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (b *WSBackend) getConnection(conn wasabi.Connection) (*websocket.Conn, erro
uws, err, _ := b.group.Do(conn.ID(), func() (interface{}, error) {
c, err := b.dialer(conn.Context(), b.URL)
if err != nil {
_ = conn.Close(websocket.StatusInternalError, "Internal Server Error")
return nil, err
}

Expand Down
2 changes: 2 additions & 0 deletions backend/ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestGetConnectionDialError(t *testing.T) {
conn := mocks.NewMockConnection(t)
conn.EXPECT().ID().Return("connection1")
conn.EXPECT().Context().Return(context.Background())
conn.EXPECT().Close(websocket.StatusInternalError, "Internal Server Error").Return(nil)

_, err := b.getConnection(conn)
if err == nil {
Expand Down Expand Up @@ -182,6 +183,7 @@ func TestWSBackend_Handle_FailToConnect(t *testing.T) {
conn := mocks.NewMockConnection(t)
conn.EXPECT().ID().Return("connection1")
conn.EXPECT().Context().Return(context.Background())
conn.EXPECT().Close(websocket.StatusInternalError, "Internal Server Error").Return(nil)

r := mocks.NewMockRequest(t)

Expand Down

0 comments on commit 15d05d3

Please sign in to comment.