Skip to content

Commit

Permalink
move defer up
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSonOfLars committed Dec 22, 2024
1 parent 2a1d9e2 commit 3b4098b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ func (u *Updater) StartPolling(b *gotgbot.Bot, opts *PollingOpts) error {

bData.updateWriterControl.Add(1)
go func() {
u.pollingLoop(ctx, bData, reqOpts, v)
// defer, so it gets called even in case of panics.
defer bData.updateWriterControl.Done()

u.pollingLoop(ctx, bData, reqOpts, v)
}()

return nil
Expand Down

0 comments on commit 3b4098b

Please sign in to comment.