fix(pkg/channles):fix the resource leak for slack.go
This commit is contained in:
parent
29d4019e62
commit
18eb0855dc
1 changed files with 2 additions and 1 deletions
|
|
@ -257,8 +257,9 @@ func (c *SlackChannel) handleMessageEvent(ev *slackevents.MessageEvent) {
|
||||||
|
|
||||||
if utils.IsAudioFile(file.Name, file.Mimetype) && c.transcriber != nil && c.transcriber.IsAvailable() {
|
if utils.IsAudioFile(file.Name, file.Mimetype) && c.transcriber != nil && c.transcriber.IsAvailable() {
|
||||||
ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
|
ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
|
||||||
defer cancel()
|
|
||||||
result, err := c.transcriber.Transcribe(ctx, localPath)
|
result, err := c.transcriber.Transcribe(ctx, localPath)
|
||||||
|
// Release context resources immediately to avoid leaks in for loop
|
||||||
|
cancel()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.ErrorCF("slack", "Voice transcription failed", map[string]any{"error": err.Error()})
|
logger.ErrorCF("slack", "Voice transcription failed", map[string]any{"error": err.Error()})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue