From 916e4c40c41ca7b74afa4405daebb2ff55010470 Mon Sep 17 00:00:00 2001 From: yibaiba <946100224@qq.com> Date: Fri, 28 Aug 2026 23:23:59 +0800 Subject: [PATCH] fix(notify): give vocall hold and resume their own timeouts The shared 8s context expired during the 3s hold pause, so resume re-INVITE was cancelled and looked like a protocol failure. Co-authored-by: Cursor --- internal/notify/commands.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/notify/commands.go b/internal/notify/commands.go index 0f6b94e3..3320a94b 100644 --- a/internal/notify/commands.go +++ b/internal/notify/commands.go @@ -695,15 +695,18 @@ func exerciseVocallHold(gw *voicehost.Gateway, deviceID string) { logger.Warn("vocall 保持跳过:没有活动通话", "device", deviceID) return } - ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second) - defer cancel() - if err := gw.HoldCall(ctx, deviceID, snap.CallID); err != nil { + holdCtx, holdCancel := context.WithTimeout(context.Background(), 8*time.Second) + err := gw.HoldCall(holdCtx, deviceID, snap.CallID) + holdCancel() + if err != nil { logger.Warn("vocall 保持失败", "device", deviceID, "call_id", snap.CallID, "err", err) return } logger.Info("vocall 已保持", "device", deviceID, "call_id", snap.CallID) time.Sleep(3 * time.Second) - if err := gw.ResumeCall(ctx, deviceID, snap.CallID); err != nil { + resumeCtx, resumeCancel := context.WithTimeout(context.Background(), 8*time.Second) + defer resumeCancel() + if err := gw.ResumeCall(resumeCtx, deviceID, snap.CallID); err != nil { logger.Warn("vocall 恢复失败", "device", deviceID, "call_id", snap.CallID, "err", err) return }