andreykaipov / goobs

Go client library for OBS Studio
Apache License 2.0
137 stars 23 forks source link

bugfix(client): panic: send on closed channel #176

Closed xaionaro closed 1 month ago

xaionaro commented 1 month ago

Fix:

panic: send on closed channel

goroutine 751872 [running]:
github.com/andreykaipov/goobs.(*Client).writeEvent(...)
    /home/xaionaro/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/andreykaipov/goobs@v1.4.1/client.go:363
github.com/andreykaipov/goobs.(*Client).handleOpcodes(0xc0020c81a0, 0xc0013846c0)
    /home/xaionaro/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/andreykaipov/goobs@v1.4.1/client.go:338 +0x5a5
created by github.com/andreykaipov/goobs.(*Client).connect in goroutine 751658
    /home/xaionaro/.gvm/pkgsets/go1.22.1/global/pkg/mod/github.com/andreykaipov/goobs@v1.4.1/client.go:200

Essentially by design we should close a channel only after we finished all possible writing to it. Thus moving the close statement of channel IncomingResponses to be called right after the writer to the channel is finished.

xaionaro commented 1 month ago

Closing in favor of https://github.com/andreykaipov/goobs/pull/179