File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,12 @@ func Dial(addr string) (net.Conn, error) {
39
39
if ! ev .Data .Get ("message" ).IsUndefined () {
40
40
return nil , fmt .Errorf ("ws.dial: %v" , js .NewError (ev .Data ))
41
41
}
42
- select {
43
- case ce := <- c .events :
44
- if ce .Type == eventClosed {
45
- code := ce .Data .Get ("code" ).Int ()
46
- return nil , fmt .Errorf ("ws.dial: connection closed with code %d" , code )
47
- }
48
- default :
42
+ // after an error the connection should switch to a closed state
43
+ ev = <- c .events
44
+ if ev .Type == eventClosed {
45
+ // unfortunately there is no way to get the real cause of an error
46
+ code := ev .Data .Get ("code" ).Int ()
47
+ return nil , fmt .Errorf ("ws.dial: connection closed with code %d" , code )
49
48
}
50
49
return nil , fmt .Errorf ("ws.dial: connection failed, see console" )
51
50
}
You can’t perform that action at this time.
0 commit comments