Skip to content

fix(api): recover from panics in the /start forward goroutine#181

Merged
devitway merged 1 commit into
mainfrom
fix/startchat-goroutine-recover
Jun 16, 2026
Merged

fix(api): recover from panics in the /start forward goroutine#181
devitway merged 1 commit into
mainfrom
fix/startchat-goroutine-recover

Conversation

@devitway

Copy link
Copy Markdown
Contributor

The inline goroutine in startChat that forwards the synthetic /start update (via updates.Push / relay.Send / sendWebhook) had no panic recovery, unlike its siblings forwardToBot and forwardCallback which both defer recoverLog. An unrecovered panic in a spawned goroutine crashes the whole process — the request-chain Recover middleware only covers the request goroutine, not ones it spawns.

Guard it the same way, and add TestRecoverLog_RecoversGoroutinePanic locking the recovery primitive (a deferred recoverLog must swallow a goroutine panic).

The inline goroutine in startChat that forwards the synthetic /start
update (via updates.Push / relay.Send / sendWebhook) had no panic
recovery, unlike its siblings forwardToBot and forwardCallback which
both defer recoverLog. An unrecovered panic in a spawned goroutine
crashes the whole process — the request-chain Recover middleware only
covers the request goroutine, not ones it spawns. Guard it the same way.

Add TestRecoverLog_RecoversGoroutinePanic locking the recovery primitive
(a deferred recoverLog must swallow a goroutine panic).
@devitway devitway merged commit 43c4cd0 into main Jun 16, 2026
9 checks passed
@devitway devitway deleted the fix/startchat-goroutine-recover branch June 16, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant