telebot icon indicating copy to clipboard operation
telebot copied to clipboard

Panic on bot.Stop() v4.0.0-beta.4

Open ofstudio opened this issue 1 year ago • 2 comments

panic: close of closed channel
goroutine 44 [running]:
gopkg.in/telebot%2ev4.(*Webhook).waitForStop(...)
	gopkg.in/[email protected]/webhook.go:161
gopkg.in/telebot%2ev4.(*Webhook).Poll.func1(0xc000450a10)
	gopkg.in/[email protected]/webhook.go:148 +0x2f
created by gopkg.in/telebot%2ev4.(*Webhook).Poll in goroutine 40
	gopkg.in/[email protected]/webhook.go:147 +0x18a

the code

go bot.Start() // 1. Start the bot
<-ctx.Done()   // 2. Wait for context cancel on SIGING or SIGTERM
bot.Stop()     // 3. Stop the bot
// ^^^^ Panic goes here!

ofstudio avatar Nov 25 '24 21:11 ofstudio

The same error with v3.3.8

 panic: close of closed channel

 goroutine 80 [running]:
 gopkg.in/telebot%2ev3.(*Webhook).waitForStop(...)
  /go/pkg/mod/gopkg.in/[email protected]/webhook.go:155
gopkg.in/telebot%2ev3.(*Webhook).Poll.func1(0xc00007ff80)
  /go/pkg/mod/gopkg.in/[email protected]/webhook.go:142 +0x2f
created by gopkg.in/telebot%2ev3.(*Webhook).Poll in goroutine 59
  /go/pkg/mod/gopkg.in/[email protected]/webhook.go:141 +0x187

evgeniy-krivenko avatar Mar 01 '25 20:03 evgeniy-krivenko

  1. Use webhook & webhook.ServeHTTP(c.Writer, c.Request) in Gin (http)
  2. bot.Start()
  3. sleep(1s)
  4. bot.Stop() -> panic!!
Image Image

molizz avatar Jun 08 '25 12:06 molizz