Skip to content

Commit

Permalink
Merge pull request #178 from codefresh-io/fix-memory-leak
Browse files Browse the repository at this point in the history
fix: fix memory leak if `timeout` is set
  • Loading branch information
apocas authored Jan 3, 2025
2 parents 1712ff1 + 15a8059 commit dc8d82a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,15 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
if (self.connectionTimeout) {
connectionTimeoutTimer = setTimeout(function () {
debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);
req.abort();
req.destroy();
}, self.connectionTimeout);
}

if (self.timeout) {
req.on('socket', function (socket) {
socket.setTimeout(self.timeout);
socket.on('timeout', function () {
debug('Timeout of %s ms exceeded', self.timeout);
req.abort();
});
req.setTimeout(self.timeout);
req.on('timeout', function () {
debug('Timeout of %s ms exceeded', self.timeout);
req.destroy();
});
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docker-modem",
"description": "Docker remote API network layer module.",
"version": "5.0.3",
"version": "5.0.4",
"author": "Pedro Dias <[email protected]>",
"maintainers": [
"apocas <[email protected]>"
Expand Down

0 comments on commit dc8d82a

Please sign in to comment.