tucnak / telebot

Telebot is a Telegram bot framework in Go.
MIT License
4.04k stars 469 forks source link

api: fix race for a stopClient channel #625

Closed odourain closed 9 months ago

odourain commented 1 year ago

Problem

Before starting the bot I do a setCommands and its goroutine [which reads channel variable] does not have time to complete before the start method [which writes to channel variable].

Previous read at 0x00c0015a6628 by goroutine 106: https://github.com/tucnak/telebot/blob/v3/api.go#L39

Write at 0x00c0015a6628 by main goroutine: https://github.com/tucnak/telebot/blob/v3/bot.go#L205

Decision

Use mutex for use channel stopClient.

Also added changes from https://github.com/caalberts/telebot to work with testnet.