LambdaTest / nightwatch-selenium-sample

Run test automation on cloud with NightwatchJS and LambdaTest. This is a sample repo to help you execute NightwatchJS framework based test scripts in parallel with LambdaTest automation testing cloud
https://www.lambdatest.com/
16 stars 34 forks source link

Error: An error occurred while retrieving a new session: "socket hang up" #8

Closed nikhil-lambda closed 4 years ago

nikhil-lambda commented 4 years ago
specs/spec1.js     POST http://hub.lambdatest.com /wd/hub/session - ECONNRESET 
 specs/spec1.js  Error: socket hang up 
 specs/spec1.js      at connResetException (internal/errors.js:612:14) 
 specs/spec1.js  ⚠ Error connecting to hub.lambdatest.com on port 80. 
Error: An error occurred while retrieving a new session: "socket hang up"
nikhil-lambda commented 4 years ago

This issue exists due to the timeout configuration in Nightwatch. Since Nightwatch internally dependent on Axios, So as per Axios documentation.

Axios link: https://github.com/axios/axios/blob/master/lib/adapters/http.js#L256

// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
  250:       // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
  251        // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
  252        // And then these socket which be hang up will devoring CPU little by little.

Resolution Increasing the timeout in Nightwatch will fix this issue. The recommended value for it 60000 ie.

  test_settings: {
    default: {
      request_timeout_options: {
        timeout: 60000,
      }
}