pico

created pr with 92.1 on 2025-12-16T04:16:16Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 92 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 92.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 92

Patchset 92.1 on 2025-12-16T04:16:16Z · commit 780f9e1

fix(pgs): memory leaks
Eric Bower 2025-12-16T04:01:27Z
All changes replace defer with immediate Close() calls to ensure resources are released promptly rather than accumulating until function return.
Semantic diff summary
0 added, 1 modified, 0 signature changed, 0 removed across 1 analyzed file
+5 -9 pkg/apps/pgs/web_asset_handler.go #
......@@ -51,10 +51,8 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
5151 logger.Info("_redirects not found in lru cache", "key", redirectsCacheKey)
5252 redirectFp, redirectInfo, err := h.Cfg.Storage.GetObject(h.Bucket, filepath.Join(h.ProjectDir, "_redirects"))
5353 if err == nil {
54- defer func() {
55- _ = redirectFp.Close()
56- }()
5754 if redirectInfo != nil && redirectInfo.Size > h.Cfg.MaxSpecialFileSize {
55+ _ = redirectFp.Close()
5856 errMsg := fmt.Sprintf("_redirects file is too large (%d > %d)", redirectInfo.Size, h.Cfg.MaxSpecialFileSize)
5957 logger.Error(errMsg)
6058 http.Error(w, errMsg, http.StatusInternalServerError)
......@@ -63,6 +61,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6361 buf := new(strings.Builder)
6462 lr := io.LimitReader(redirectFp, h.Cfg.MaxSpecialFileSize)
6563 _, err := io.Copy(buf, lr)
64+ _ = redirectFp.Close()
6665 if err != nil {
6766 logger.Error("io copy", "err", err.Error())
6867 http.Error(w, "cannot read _redirects file", http.StatusInternalServerError)
......@@ -109,9 +108,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
109108 if err != nil {
110109 continue
111110 }
112- defer func() {
113- _ = obj.Close()
114- }()
111+ _ = obj.Close()
115112 }
116113 logger.Info(
117114 "redirecting request",
......@@ -219,10 +216,8 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
219216 logger.Info("_headers not found in lru cache", "key", headersCacheKey)
220217 headersFp, headersInfo, err := h.Cfg.Storage.GetObject(h.Bucket, filepath.Join(h.ProjectDir, "_headers"))
221218 if err == nil {
222- defer func() {
223- _ = headersFp.Close()
224- }()
225219 if headersInfo != nil && headersInfo.Size > h.Cfg.MaxSpecialFileSize {
220+ _ = headersFp.Close()
226221 errMsg := fmt.Sprintf("_headers file is too large (%d > %d)", headersInfo.Size, h.Cfg.MaxSpecialFileSize)
227222 logger.Error(errMsg)
228223 http.Error(w, errMsg, http.StatusInternalServerError)
......@@ -231,6 +226,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
231226 buf := new(strings.Builder)
232227 lr := io.LimitReader(headersFp, h.Cfg.MaxSpecialFileSize)
233228 _, err := io.Copy(buf, lr)
229+ _ = headersFp.Close()
234230 if err != nil {
235231 logger.Error("io copy", "err", err.Error())
236232 http.Error(w, "cannot read _headers file", http.StatusInternalServerError)
Back to top