Skip to content
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

Fixes/3649 use same http agent for requests #3748

Conversation

gravityvi
Copy link
Member

Changes

  • use a single instance of HTTP agent for requests

Impacts

@github-actions
Copy link

Status

  • ❌ No modified files found in the types directory.
    Please make sure to include types for any changes you have made. Thank you!.

lib/http/request.js Outdated Show resolved Hide resolved
Copy link
Member

@swrdfish swrdfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

lib/http/request.js Outdated Show resolved Hide resolved
@gravityvi gravityvi requested a review from beatfactor May 25, 2023 09:59
}

static getHttpKeepAliveAgent({keepAliveMsecs, maxSockets}) {
if (!__httpKeepAliveAgent__) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting to refactor this into something like

function getAgent(secure) {
  const protocol = secure ? https : http;
  return __httpKeepAliveAgent__ = new protocol.Agent({
      keepAlive: true,
      keepAliveMsecs,
      maxSockets
    });
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored and removed __httpsKeepAliveAgent__ as we would need only a variable per test session/process (either http or https agent). For multiple envs we use worker_threads or child process which won't share instances of global variables.

@beatfactor beatfactor merged commit 525e4c1 into nightwatchjs:main May 26, 2023
16 of 17 checks passed
harshit-bs pushed a commit to harshit-bs/nightwatch that referenced this pull request Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

keep_alive not getting honoured
4 participants