fix memory leak, close file after serve
This commit is contained in:
parent
4e1ac5888a
commit
784a34ed4d
2
mod.ts
2
mod.ts
|
@ -169,12 +169,14 @@ export class HTTPServer {
|
||||||
|
|
||||||
const readableStream = file.readable;
|
const readableStream = file.readable;
|
||||||
const response = new Response(readableStream);
|
const response = new Response(readableStream);
|
||||||
|
|
||||||
if (middlewarePromise) {
|
if (middlewarePromise) {
|
||||||
const pt = performance.now() - perStart;
|
const pt = performance.now() - perStart;
|
||||||
const hrArray: number[] = [0, Math.trunc(pt * 1000000)];
|
const hrArray: number[] = [0, Math.trunc(pt * 1000000)];
|
||||||
resolveAction(hrArray);
|
resolveAction(hrArray);
|
||||||
}
|
}
|
||||||
await requestEvent.respondWith(response);
|
await requestEvent.respondWith(response);
|
||||||
|
file.close(); // close file after serve
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user