Destroy static file stream when response closes
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
f5b1b638ce
commit
845ab9a76b
1 file changed
+3
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user