You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When CloseNow() is called by 2 goroutines, there is a race condition:
panic: sync: WaitGroup is reused before previous Wait has returned
goroutine 105321 [running]:
sync.(*WaitGroup).Wait(0xe33400?)
/src/sync/waitgroup.go:118 +0x74
nhooyr.io/websocket.(*Conn).CloseNow(0xc02d1e5860)
/.go/pkg/mod/nhooyr.io/websocket@v1.8.10/close.go:113 +0xcb
Original func
func (c *Conn) CloseNow() (err error) {
defer c.wg.Wait()
defer errd.Wrap(&err, "failed to close WebSocket")
if c.isClosed() {
return net.ErrClosed
}
...
}
Possible fix: move defer calls below isClosed()
func (c *Conn) CloseNow() (err error) {
if c.isClosed() {
return net.ErrClosed
}
defer c.wg.Wait()
defer errd.Wrap(&err, "failed to close WebSocket")
...
}
The text was updated successfully, but these errors were encountered:
nhooyr
added a commit
to alixander/websocket
that referenced
this issue
Apr 5, 2024
nhooyr.io/websocket v1.8.10
When CloseNow() is called by 2 goroutines, there is a race condition:
Original func
Possible fix: move defer calls below isClosed()
The text was updated successfully, but these errors were encountered: