Skip to content

Commit

Permalink
Merge pull request #126 from ksysoev/improve_ws_backend
Browse files Browse the repository at this point in the history
Fix internal server error when dialing websocket connection
  • Loading branch information
ksysoev authored Oct 1, 2024
2 parents 1ad9c3b + 15d05d3 commit a46a8b5
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 a46a8b5

Please sign in to comment.