-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Because Goβs runtime (goruntime) uses preemptive scheduling, when multiple goroutines run concurrently, the execution order may not always match the expected logic. See:
socket.io/servers/socket/client.go
Line 211 in a3cd609
| go socket._onpacket(packet) |
socket.io/servers/socket/socket.go
Lines 701 to 711 in a3cd609
| go func(err error) { | |
| if err != nil { | |
| s._onerror(err) | |
| return | |
| } | |
| if s.Connected() { | |
| s.EmitUntyped(slices.TryGetAny[string](event, 0), slices.Slice(event, 1)...) | |
| } else { | |
| socket_log.Debug("ignore packet received after disconnection") | |
| } | |
| }(err) |
socket.io/servers/socket/namespace.go
Lines 271 to 297 in a3cd609
| go func() { | |
| if client.conn.ReadyState() != "open" { | |
| namespace_log.Debug("next called after client was closed - ignoring socket") | |
| socket._cleanup() | |
| return | |
| } | |
| if err != nil { | |
| namespace_log.Debug("middleware error, sending CONNECT_ERROR packet to the client") | |
| socket._cleanup() | |
| if client.conn.Protocol() == 3 { | |
| if e := err.Data(); e != nil { | |
| socket._error(e) | |
| return | |
| } | |
| socket._error(err.Error()) | |
| return | |
| } else { | |
| socket._error(map[string]any{ | |
| "message": err.Error(), | |
| "data": err.Data(), | |
| }) | |
| return | |
| } | |
| } | |
| n._doConnect(socket, fn) | |
| }() |
| go s._onClose("ping timeout", nil) |
| go w.send(packets) |
| go w.send(packets) |
and more goruntime logic...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working