diff --git a/internal/shared/component_report/handler.go b/internal/shared/component_report/handler.go index 7bbc15c..921f6b5 100644 --- a/internal/shared/component_report/handler.go +++ b/internal/shared/component_report/handler.go @@ -397,14 +397,9 @@ func (h *ComponentReportHandler) GenerateAndDownloadZip(c *gin.Context) { } }() - // 创建带超时的上下文,避免ZIP生成时间过长导致网关超时 - // 设置超时时间为 25 秒,略小于服务器的 write_timeout (30秒) - ctx, cancel := context.WithTimeout(c.Request.Context(), 25*time.Second) - defer cancel() - // 生成ZIP文件 zipPath, err := h.zipGenerator.GenerateZipFile( - ctx, + c.Request.Context(), req.ProductID, req.SubProductCodes, h.exampleJSONGenerator, @@ -412,18 +407,6 @@ func (h *ComponentReportHandler) GenerateAndDownloadZip(c *gin.Context) { ) if err != nil { h.logger.Error("生成ZIP文件失败", zap.Error(err), zap.String("product_id", req.ProductID)) - - // 检查是否是超时错误 - if ctx.Err() == context.DeadlineExceeded { - h.logger.Error("ZIP文件生成超时", zap.String("product_id", req.ProductID)) - c.JSON(http.StatusRequestTimeout, gin.H{ - "code": 504, - "message": "文件生成超时,请稍后重试", - "error": "请求处理时间过长", - }) - return - } - c.JSON(http.StatusInternalServerError, gin.H{ "code": 500, "message": "生成ZIP文件失败",