Destroy static file stream when response closes

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 02:30:05 +00:00
1 parent f5b1b638ce
commit 845ab9a76b
1 file changed
+3
+3
View File
@@ -745,6 +745,9 @@ function startStaticWebServer(distRoot: string, port: number) {
});
const stream = fs.createReadStream(targetPath);
response.on("close", () => {
stream.destroy();
});
stream.on("error", () => {
if (!response.headersSent) {
respondText(404, "Not found");