Skip to content

Panic during eventsocket reconnect testing #212

@iProdigy

Description

@iProdigy

Was testing my eventsub websocket reconnect implementation and randomly encountered this panic from the cli (but subsequent testing hasn't reproduced the error):

panic: runtime error: slice bounds out of range [1:0]

goroutine 38 [running]:
github.com/twitchdev/twitch-cli/internal/events/mock_wss_server.onCloseConnection(0x0?, 0xc0001a40f0?)
        /go/src/github.com/twitchdev/twitch-cli/internal/events/mock_wss_server/server.go:243 +0x1ac
github.com/twitchdev/twitch-cli/internal/events/mock_wss_server.eventsubHandle.func4()
        /go/src/github.com/twitchdev/twitch-cli/internal/events/mock_wss_server/server.go:193 +0x208
created by github.com/twitchdev/twitch-cli/internal/events/mock_wss_server.eventsubHandle
        /go/src/github.com/twitchdev/twitch-cli/internal/events/mock_wss_server/server.go:175 +0x838

wsSrv.connections = append(wsSrv.connections[:c], wsSrv.connections[c+1:]...)

 

The other strange thing in the logs is Disconnected websocket repeats multiple times for the same websocket id:

2023/02/05 18:42:00 Starting mock EventSub WebSocket servers on ws://localhost:8080/eventsub (alternate on port 8081)
2023/02/05 18:42:00 `Ctrl + C` to exit mock servers.
2023/02/05 18:42:00 Started alternate EventSub websocket server on port 8081. This one is used for reconnect testing.
2023/02/05 18:42:00 Mock EventSub websocket server started on port 8080
2023/02/05 18:42:20 First client connected; Reconnect testing enabled. Notices will be sent in 30 seconds.
2023/02/05 18:42:20 [Server 0] Connections: (1) [ 93413566-cd0a-5e19-5c22-56b504cc7757 ]
2023/02/05 18:42:50 Terminating server 0 with reconnect notice. Disallowing connections in 30 seconds.
2023/02/05 18:42:50 Server "not accepting connections" status: [Server 0: true, Server 1: false]
2023/02/05 18:42:50 Sent reconnect notice to 93413566-cd0a-5e19-5c22-56b504cc7757
2023/02/05 18:42:50 Reconnect notices sent for server 0
2023/02/05 18:42:50 Use this new URL for connections: ws://localhost:8081/eventsub
2023/02/05 18:42:50 [Server 1] Connections: (1) [ a99cdcd3-d8b1-400b-d3b8-e0adac38de4c ]
2023/02/05 18:42:50 read: websocket: close 1000 (normal)
2023/02/05 18:42:50 Disconnected websocket 93413566-cd0a-5e19-5c22-56b504cc7757
2023/02/05 18:42:50 [Server 0] Connections: (0) [  ]
2023/02/05 18:42:50 Disconnected websocket 93413566-cd0a-5e19-5c22-56b504cc7757
2023/02/05 18:42:50 Disconnected websocket 93413566-cd0a-5e19-5c22-56b504cc7757

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions