From 3b4098b24cadb466c0f5ec4304a8fba4e8218dcb Mon Sep 17 00:00:00 2001 From: Paul Larsen Date: Sun, 22 Dec 2024 11:05:55 +0100 Subject: [PATCH] move defer up --- ext/updater.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/updater.go b/ext/updater.go index 7e8b192..c67de09 100644 --- a/ext/updater.go +++ b/ext/updater.go @@ -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