go-driver icon indicating copy to clipboard operation
go-driver copied to clipboard

Goroutines leak in notify listener

Open zeslava opened this issue 3 years ago • 0 comments

Here is sending message for notify listeners: https://github.com/arangodb/go-driver/blob/master/vst/protocol/message.go#L58

Here are 2 reads from this channel:

  1. https://github.com/arangodb/go-driver/blob/master/vst/connection.go#L169
  2. https://github.com/arangodb/go-driver/blob/master/vst/authentication.go#L143

If readers doesn't read from channel, then write is locked and goroutine leak. In 1st case it's possible when context.Done() In 2nd case - when conn.Send returns error

Possible solutions:

  • Write to channel with context + select(such as read in 1st)
  • When context is done while read, then continue read channel in goroutine then just log or smth

zeslava avatar Aug 06 '21 16:08 zeslava