fix(pkg/channles):fix the resource leak for slack.go

This commit is contained in:
ItsT0ng 2026-03-01 01:03:30 +11:00
parent 29d4019e62
commit 18eb0855dc

View file

@ -257,8 +257,9 @@ func (c *SlackChannel) handleMessageEvent(ev *slackevents.MessageEvent) {
if utils.IsAudioFile(file.Name, file.Mimetype) && c.transcriber != nil && c.transcriber.IsAvailable() {
ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
defer cancel()
result, err := c.transcriber.Transcribe(ctx, localPath)
// Release context resources immediately to avoid leaks in for loop
cancel()
if err != nil {
logger.ErrorCF("slack", "Voice transcription failed", map[string]any{"error": err.Error()})