Skip to content

Commit

Permalink
turn on http keep alive while using ChromeDriver (#5759)
Browse files Browse the repository at this point in the history
* turn on http keep alive while using ChromeDriver

need chrome driver 2.35 or above
fix #5758

* add ECONNREFUSED as retryable network error

after enable HTTP keep alive, chromedriver sometimes refused connection
  • Loading branch information
awarecan authored and jleyba committed Dec 15, 2018
1 parent 105994c commit 6adc9dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion javascript/node/selenium-webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ const Command = {
* @return {!command.Executor} The new command executor.
*/
function createExecutor(url) {
let client = url.then(url => new http.HttpClient(url));
let agent = new http.Agent({ keepAlive: true });
let client = url.then(url => new http.HttpClient(url, agent));
let executor = new http.Executor(client);
configureExecutor(executor);
return executor;
Expand Down
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ function isRetryableNetworkError(err) {
if (err && err.code) {
return err.code === 'ECONNABORTED' ||
err.code === 'ECONNRESET' ||
err.code === 'ECONNREFUSED' ||
err.code === 'EADDRINUSE' ||
err.code === 'EPIPE';
}
Expand All @@ -297,6 +298,7 @@ function isRetryableNetworkError(err) {

// PUBLIC API

exports.Agent = http.Agent;
exports.Executor = httpLib.Executor;
exports.HttpClient = HttpClient;
exports.Request = httpLib.Request;
Expand Down

0 comments on commit 6adc9dc

Please sign in to comment.