From 784a34ed4dd4151fa84554866793a7debf2ef298 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Fri, 12 May 2023 14:49:21 +0200 Subject: [PATCH] fix memory leak, close file after serve --- mod.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mod.ts b/mod.ts index de9fc02..d5f4d9f 100644 --- a/mod.ts +++ b/mod.ts @@ -169,12 +169,14 @@ export class HTTPServer { const readableStream = file.readable; const response = new Response(readableStream); + if (middlewarePromise) { const pt = performance.now() - perStart; const hrArray: number[] = [0, Math.trunc(pt * 1000000)]; resolveAction(hrArray); } await requestEvent.respondWith(response); + file.close(); // close file after serve return; }