Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from stegano/feature/fix-memory-leaks
Browse files Browse the repository at this point in the history
fix: event handler not removed after responding to request
stegano authored Mar 12, 2022
2 parents 2453215 + 784efa8 commit ba02109
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -85,8 +85,14 @@ const httpProxyMiddleware = async (
proxyReq.end();
}
}) as any)
.once("proxyRes", resolve as any)
.once("error", reject)
.once("proxyRes", ((proxyRes: any) => {
proxy.removeAllListeners();
return reject(proxyRes)
}) as any)
.once("error", ((err: any) => {
proxy.removeAllListeners();
return reject(err);
}) as any)
.web(req, res, {
changeOrigin: true,
...serverOptions

0 comments on commit ba02109

Please sign in to comment.