go-stomp / stomp

Go language library for STOMP protocol
Apache License 2.0
318 stars 95 forks source link

panic: send on closed channel #134

Closed aletheia7 closed 2 months ago

aletheia7 commented 6 months ago

Version: v3.1.0

Getting golang "panic: send on closd channel" error on Subscribe and Unsubscribe.

panic: send on closed channel
goroutine 31 [running]:
github.com/go-stomp/stomp/v3.(*Subscription).closeChannel(...)
        github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:150
github.com/go-stomp/stomp/v3.(*Subscription).Unsubscribe(0xc00030e0c0?, {0x0, 0x0, 0x0?})
        github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:89 +0x51c
panic: send on closed channel
goroutine 127 [running]:
github.com/go-stomp/stomp/v3.(*Subscription).closeChannel(...)
        github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:150
github.com/go-stomp/stomp/v3.(*Subscription).readLoop(0xc000316600, 0xc0003c04e0)
        github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:210 +0x8f3
created by github.com/go-stomp/stomp/v3.(*Conn).Subscribe in goroutine 48
        github.com/go-stomp/stomp/v3@v3.1.0/conn.go:696 +0x989
circadi commented 5 months ago

Same issue observed when upgrading to 3.1.0:

panic: send on closed channel

goroutine 98 [running]:
github.com/go-stomp/stomp/v3.(*Subscription).closeChannel(...)
        /home/dev/.gvm/pkgsets/go1.21.8/global/pkg/mod/github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:150
github.com/go-stomp/stomp/v3.(*Subscription).Unsubscribe(0x0?, {0x0, 0x0, 0x0?})
        /home/dev/.gvm/pkgsets/go1.21.8/global/pkg/mod/github.com/go-stomp/stomp/v3@v3.1.0/subscription.go:89 +0x533

Version 3.0.5 doesn't have this bug when unsubscribe, I suspect it's due to the following fix that closed the channel:

https://github.com/go-stomp/stomp/compare/v3.0.5...v3.0.6

worg commented 2 months ago

closed by #135