From d6aafa41ff8370782ef2f6a206bc3f9f4d3356ca Mon Sep 17 00:00:00 2001 From: "3371392206@qq.com" <3371392206@qq.com> Date: Sat, 12 Sep 2026 15:53:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(tts):=20OpenaiTTSHandler=20=E5=93=8D?= =?UTF-8?q?=E5=BA=94=20Write=20=E9=94=99=E8=AF=AF=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E5=90=9E,=E8=AE=B0=E6=97=A5=E5=BF=97=E6=8E=92=E6=9F=A5?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=96=AD=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/tts.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controller/tts.go b/controller/tts.go index d0c6e05..3c4e7b7 100644 --- a/controller/tts.go +++ b/controller/tts.go @@ -232,7 +232,11 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Length", fmt.Sprintf("%d", len(result.AudioData))) w.Header().Set("X-Request-Id", result.ReqID) w.WriteHeader(http.StatusOK) - w.Write(result.AudioData) + if n, err := w.Write(result.AudioData); err != nil { + // header 已发,无法改 status code;只记日志供排查(常见:客户端中途断开 → broken pipe / connection reset) + log.Printf("警告: 响应写入失败 - 路径=%s 客户端=%s 已写=%d/%d 错误=%v", + r.URL.Path, middleware.GetClientIP(r), n, len(result.AudioData), err) + } } func classifyStatus(err error) string {