Skip to content

Commit

Permalink
fix: reset timeout after secureConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Oct 24, 2019
1 parent a703be1 commit 60b4f7c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
},
"dependencies": {
"boolean": "^2.0.2",
"core-js": "^3.3.2",
"core-js": "^3.3.3",
"es6-error": "^4.1.1",
"matcher": "^2.0.0",
"roarr": "^2.14.1",
"roarr": "^2.14.2",
"semver": "^6.3.0",
"serialize-error": "^5.0.0"
},
Expand All @@ -43,15 +43,15 @@
"coveralls": "^3.0.7",
"eslint": "^6.5.1",
"eslint-config-canonical": "^17.7.0",
"flow-bin": "^0.109.0",
"flow-bin": "^0.110.1",
"flow-copy-source": "^2.0.8",
"get-port": "^5.0.0",
"got": "^9.6.0",
"husky": "^3.0.9",
"nyc": "^14.1.1",
"pem": "^1.14.3",
"request": "^2.88.0",
"semantic-release": "^15.13.24",
"semantic-release": "^15.13.27",
"sinon": "^7.5.0"
},
"engines": {
Expand Down
16 changes: 16 additions & 0 deletions src/classes/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,29 @@ class Agent {

// $FlowFixMe It appears that Flow is missing the method description.
this.createConnection(connectionConfiguration, (error, socket) => {
log.trace({
target: connectionConfiguration,
}, 'connecting');

// @see https://github.com/nodejs/node/issues/5757#issuecomment-305969057
if (socket) {
socket.setTimeout(this.socketConnectionTimeout, () => {
socket.destroy();
});

socket.once('connect', () => {
log.trace({
target: connectionConfiguration,
}, 'connected');

socket.setTimeout(0);
});

socket.once('secureConnect', () => {
log.trace({
target: connectionConfiguration,
}, 'connected (secure)');

socket.setTimeout(0);
});
}
Expand Down

0 comments on commit 60b4f7c

Please sign in to comment.