Skip to content

Commit dc8d82a

Browse files
authored
Merge pull request #178 from codefresh-io/fix-memory-leak
fix: fix memory leak if `timeout` is set
2 parents 1712ff1 + 15a8059 commit dc8d82a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/modem.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,15 @@ Modem.prototype.buildRequest = function (options, context, data, callback) {
283283
if (self.connectionTimeout) {
284284
connectionTimeoutTimer = setTimeout(function () {
285285
debug('Connection Timeout of %s ms exceeded', self.connectionTimeout);
286-
req.abort();
286+
req.destroy();
287287
}, self.connectionTimeout);
288288
}
289289

290290
if (self.timeout) {
291-
req.on('socket', function (socket) {
292-
socket.setTimeout(self.timeout);
293-
socket.on('timeout', function () {
294-
debug('Timeout of %s ms exceeded', self.timeout);
295-
req.abort();
296-
});
291+
req.setTimeout(self.timeout);
292+
req.on('timeout', function () {
293+
debug('Timeout of %s ms exceeded', self.timeout);
294+
req.destroy();
297295
});
298296
}
299297

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "docker-modem",
33
"description": "Docker remote API network layer module.",
4-
"version": "5.0.3",
4+
"version": "5.0.4",
55
"author": "Pedro Dias <[email protected]>",
66
"maintainers": [
77
"apocas <[email protected]>"

0 commit comments

Comments
 (0)