Skip to content

implement memory leak fix from http-proxy #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions app/steps/sendProxyRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var chunkLength = require('../../lib/chunkLength');

function defaultSendProxyRequest(Container) {
var req = Container.user.req;
var res = Container.user.res;
var bodyContent = Container.proxy.bodyContent;
var reqOpt = Container.proxy.reqBuilder;
var options = Container.options;
Expand Down Expand Up @@ -67,11 +68,25 @@ function defaultSendProxyRequest(Container) {
req.pipe(proxyReq);
}

req.on('aborted', function () {
// reject?
// 'aborted' event stopped working reliably on v15.5.0 and was later removed entirely
var supportsAbortedEvent = (function () {
var ver = process.versions.node.split('.').map(Number);
return ver[0] <= 14 || ver[0] === 15 && ver[1] <= 4;
}());

proxyReq.abort();
});
if (supportsAbortedEvent) {
req.on('aborted', function () {
// reject?
proxyReq.abort();
});
} else {
res.on('close', function () {
var aborted = !res.writableFinished;
if (aborted) {
proxyReq.abort();
}
});
}
});
}

Expand Down