From 3c4c2b56600b0d0b600958612feb8a58ee4f4b4e Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Wed, 1 Nov 2023 17:53:57 +0800 Subject: [PATCH] fix error response code --- process.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/process.go b/process.go index 9bbfd76..c381984 100644 --- a/process.go +++ b/process.go @@ -76,6 +76,9 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s if !haveResponse { log.Println("Timeout upstream", upstream.Endpoint) errCtx = errors.New("timeout") + if shouldResponse { + c.AbortWithError(502, errCtx) + } cancel() } }() @@ -130,8 +133,6 @@ func processRequest(c *gin.Context, upstream *OPENAI_UPSTREAM, record *Record, s haveResponse = true log.Println("Error", err, upstream.SK, upstream.Endpoint) - log.Println("debug", r) - errCtx = err // abort to error handle