Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: unlink finalized first temp file in fail() path

Adam Eivy6d0b512b7161
diff --git a/server/lib/multipart.js b/server/lib/multipart.js
index 396eae760c..74124cddbc 100644
--- a/server/lib/multipart.js
+++ b/server/lib/multipart.js
@@ -100,6 +100,12 @@ function streamMultipart(req, boundary, fileFieldNames, maxSize, fileFilter, nex
// Best-effort cleanup of the partially-written file.
if (writePath) unlink(writePath).catch(() => {});
}
+ // Also unlink any already-finalized file. Matters for the TOO_MANY_FILES
+ // path: the first accepted file part has already flushed to disk and is
+ // sitting at fileResult.path before the second part triggers fail().
+ // Without this, every TOO_MANY_FILES rejection leaks the first temp
+ // file in the OS tmp dir.
+ if (fileResult?.path) unlink(fileResult.path).catch(() => {});
req.removeAllListeners('data');
next(err);
};