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

"socket hang up" on Nightwatch v1.0.14 mid-test #1936

Closed
lukasbach opened this issue Nov 27, 2018 · 59 comments
Closed

"socket hang up" on Nightwatch v1.0.14 mid-test #1936

lukasbach opened this issue Nov 27, 2018 · 59 comments
Labels

Comments

@lukasbach
Copy link

lukasbach commented Nov 27, 2018

I am getting this error in 1.0.14. It seems mostly similar to #1788.

   POST  /wd/hub/session/d9ab872e5e220f21392bea9998a366e7/elements - ECONNRESET
       Error: socket hang up
     at createHangUpError (_http_client.js:322:15)
     at Socket.socketCloseListener (_http_client.js:363:25)
       Error while running .locateMultipleElements() protocol action: An unknown error has occurred.

The error always appears mid-test, after many instructions have been completed sucessfully. It appears at a random point during the test, and at that point all following nightwatch instructions fail with this error.

I am using nightwatch@1.0.14, chromedriver@2.44.0, chrome@70.0 on Windows 10 Enterprise (1709 Build 16299.785).

Edit: My nightwatch config looks like this: https://gist.github.com/lukasbach/f121ec9a4b7a7c337d2ebb0140476d37

@lukasbach
Copy link
Author

@beatfactor Any idea what this could be caused by? I am getting this error both on my local testing setup as well as an CI setup (external linux based Jenkins server, which runs tests on a selenoid cluster).

@Deep27
Copy link

Deep27 commented Dec 27, 2018

I've faced the same issue. Using Nightwatch v.1.0.17.
When I updated chromedriver to 2.45 and google chrome to 71.0.3568.98, it's gone.
I use Windows 7.

Here is my config:

{
  "src_folders": [
    "./app/src/test/tests/"
  ],
  "output_folder": "reports",
  "custom_commands_path": "./test/commands/",
  "custom_assertions_path": "./test/assertions/",
  "page_objects_path": [
    "./app_5_0/src/test/page_objects/"
  ],
  "globals_path": "./test/globals.js",
  "webdriver": {
    "start_process": true,
    "server_path": "dev\\drivers\\windows\\chromedriver-2.45.exe",
    "port": 9515
  },
  "test_settings": {
    "default": {
      "skip_testcases_on_fail": false,
      "launch_url": "http://localhost:8081",
      "silent": true,
      "desiredCapabilities": {
        "browserName": "chrome",
        "acceptSslCerts": true,
        "acceptInsecureCerts": true,
        "javascriptEnabled": true
      }
    }
  }
}

@StephanBijzitter
Copy link

I'm getting the same with Firefox, also in the middle of a test run.

Mac OS X
Firefox 64
Geckodriver 0.23.0 (webdriver)
Nightwatch 1.0.18

  "webdriver": {
    "port": 4444,
    "start_process": true,
    "server_path": "node_modules/selenium-standalone/.selenium/geckodriver/0.23.0-x64-geckodriver"
  },
1546427699040	mozrunner::runner	INFO	Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/var/folders/b1/r9rt0f054g585pw0thgyc_z80000gn/T/rust_mozprofile.shTTVKiBEw3O"
1546427699489	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: resource://pdf.js/
1546427699489	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: about:reader*
Can't find symbol 'GetGraphicsResetStatus'.
1546427700828	Marionette	INFO	Listening on port 58759
JavaScript warning: https://d2j6bcwbysm0gv.cloudfront.net/mobile.45af4a1979f5b984e66491686ad4ca6f.js, line 14: unreachable code after return statement
JavaScript warning: https://d2j6bcwbysm0gv.cloudfront.net/mobile.45af4a1979f5b984e66491686ad4ca6f.js, line 14: unreachable code after return statement
JavaScript warning: https://d2j6bcwbysm0gv.cloudfront.net/mobile.45af4a1979f5b984e66491686ad4ca6f.js, line 14: unreachable code after return statement
JavaScript warning: https://d2j6bcwbysm0gv.cloudfront.net/mobile.45af4a1979f5b984e66491686ad4ca6f.js, line 14: unreachable code after return statement
1546427720021	Marionette	INFO	Stopped listening on port 58759
1546427720480	mozrunner::runner	INFO	Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-foreground" "-no-remote" "-profile" "/var/folders/b1/r9rt0f054g585pw0thgyc_z80000gn/T/rust_mozprofile.vAE7WL9bnX32"
1546427720925	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: resource://pdf.js/
1546427720925	addons.webextension.screenshots@mozilla.org	WARN	Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid host permission: about:reader*
Can't find symbol 'GetGraphicsResetStatus'.
1546427722232	Marionette	INFO	Listening on port 58929
console.error: BroadcastService: 
  receivedBroadcastMessage: handler for
  remote-settings/monitor_changes
  threw error:
  Message: Error: Polling for changes failed: NetworkError when attempting to fetch resource..
  Stack:
    remoteSettingsFunction/remoteSettings.pollChanges@resource://services-settings/remote-settings.js:750:13

Sidenote: start_process also doesn't work, I still have to start it manually

@lukasbach
Copy link
Author

Update: The problem does still occur for me on the earliest version of nightwatch, 1.0.18 (chromedriver 2.45.0, selenium-server 3.141.59, Google Chrome 71.0.3578.98).

@marian-r
Copy link
Contributor

I've faced this error, when testing for new tab being opened and trying to get URL or page elements too quickly before the page is loaded. The following fails:

browser.url('http://localhost/test.html')
    .waitForElementPresent('a')
    .click('a')
    .windowHandles(result => {
      browser
          .switchWindow(result.value[1])
          .assert.urlContains('https://www.example.com');
    })
    .end();

But adding a 1s pause resolves it:

browser.url('http://localhost/test.html')
    .waitForElementPresent('a')
    .click('a')
    .windowHandles(result => {
      browser
          .switchWindow(result.value[1])
          .pause(1000) // Let's pause for a sec.
          .assert.urlContains('https://www.example.com');
    })
    .end();

@venkata-018
Copy link

venkata-018 commented Jan 22, 2019

facing same issue with 500 post error with
"selenium-download": "2.0.13",
"selenium-server-standalone-jar": "3.141.5",
"selenium-standalone": "6.15.4",
"chromedriver": "2.45.0",
Response 500 POST /wd/hub/session/d9bc44a9a748a07cdf8cb15aace10797/element/0.2789049356657476-21/elements (16ms)
{ value:
{ error: [],
message:
'java.net.SocketException: Connection reset by peer (connect failed)' },
status: 13 }
Error while running .locateMultipleElementsByElementId() protocol action: java.net.SocketException: Connection reset by peer (connect failed)

Response 500 POST /wd/hub/session/d9bc44a9a748a07cdf8cb15aace10797/element/0.2789049356657476-23/elements (121ms)
{ value:
{ error: [],
message:
'java.net.SocketException: Connection reset by peer (connect failed)' },
status: 13 } Please help me get rid of this error..
Error while running .locateMultipleElementsByElementId() protocol action: java.net.SocketException: Connection reset by peer (connect failed

@Deep27
Copy link

Deep27 commented Jan 28, 2019

After we started using Moon for parallel tests, again, we had the same "socket hang up" error.

  ...
  "test_settings": {
    "default": {
      "request_timeout_options": {
        "timeout": 100000
      },
      ...

Adding timeout with enough large value helped to solve the problem.
(Moon 1.3.3, NightwatchJS 1.0.17)

@Kushagra8888
Copy link

I am not able to reliably reproduce the error. The same tests would sometimes throw this error and sometimes don't. Regardless, it does not affect the outcome of the test.

In my particular case it happens when there's a spinner on the screen and I am waiting for the an element to be present. Have tried the expect as well as the chained command flavours of tests and that does not seemed to have an effect.

@vkyt
Copy link

vkyt commented May 3, 2019

Running into the same issue with latest chromedriver@74.0.0 and nightwatch v1.0.19
In my case I'm running into socket hang up error a lot at browser.url(my_url) and browser.deleteCookies()

    POST  /session/cf3823f14a1b3462130539955c273235/url - ECONNRESET
Error: socket hang up
    at createHangUpError (_http_client.js:342:15)
    at Socket.socketCloseListener (_http_client.js:377:23)
 Error while running .navigateTo() protocol action: An unknown error has occurred.
   Request DELETE  /session/bc8c44f9e390f9416559c6a9c1bae809/cookie
    DELETE  /session/bc8c44f9e390f9416559c6a9c1bae809/cookie - ECONNRESET
Error: socket hang up
    at createHangUpError (_http_client.js:342:15)
    at Socket.socketCloseListener (_http_client.js:377:23)
 Error while running .deleteAllCookies() protocol action: An unknown error has occurred.

@aberonni
Copy link
Collaborator

+1 having the same issue sporadically - not able to reproduce consistently

@beatfactor
Copy link
Member

How about the workaround that @Deep27 suggested?

@eponymz
Copy link

eponymz commented Jun 5, 2019

Seeing this as well more often than not. I will try the workaround, but when time is of the essence it isn't optimal to make the tests take longer. Is there a root cause known? Seeing this when running with test_workers on Nightwatch v1.0.19, Chrome v74.0.3729.169, chromedriver v2.46.0

@aberonni
Copy link
Collaborator

aberonni commented Jul 9, 2019

The workaround partially mitigates but does not totally eradicate the issue - testing with the latest nightwatch version. #1936 (comment) this seems to be the closest to reproducing it but still not enough info (and I can't reproduce in isolation).

This also is confirmed a regression with v1 - did not happen with older versions.

@kiran-ghe
Copy link

I updated the chrome version to 75.0.1 and somehow I don't see this issue on my machine anymore.

@edwardxia
Copy link

For anyone who is running in to this, I can tell this is a network issue and I have a reliable re-pro described in #2147. However, I get different behavior on CentOS vs Ubuntu. It would be helpful for whoever running into this issue to report:

  1. Is it only 1 operation fail, or all operations after it fails.
  2. What kind of OS and version you're running.

@aberonni
Copy link
Collaborator

I think there might be more than one issue here. I don't think it is necessarily always a network issue, simply because this didn't seem to be happening on older versions.

If somehow it is connected to the network issue, it means that in older versions of nightwatch this was somehow handled gracefully.

@LoganBarnett
Copy link

My team has been running into this issue during a package upgrade endeavor. We downgraded Nightwatch to the last known working version for us (1.0.19) and still encountered the error. Downgrading Node to a prior version (10.7.0) fixed the issue.

I'm not sure which versions will also work - we're trying to figure that out now. I'm also not sure how Node is involved in the issue yet (do newer Node versions have a bug, or is there some change that Nightwatch hasn't accounted for?). I'll post again when I have more information.

@LoganBarnett
Copy link

This problem manifests between Node 10.15.0 (working) and 10.15.1 (breaking). With the delta in the changelog, I'm not surprised that a patch version caused the break. It may take some digging to figure out what changed that couldn't caused this issue in Nightwatch though. I've upgraded Nightwatch as part of this test as well and the breaking/working is consistent with Node versions.

@beatfactor
Copy link
Member

@LoganBarnett thanks for your insights. Can you tell us which OS platform your team is using to run the tests? And if you don't mind too much, it would be awesome if you could tell us a little bit about your project here: #2154

@LoganBarnett
Copy link

@beatfactor Our test suite is running on the Docker Node.JS image as a base. So in that sense, it's a Debian based Linux.

This is our Dockerfile:

FROM node:10.15.0

ARG UID=<REDACTED>
ARG GID=<REDACTED>
ARG USER=<REDACTED>

USER root

RUN (groupadd $USER -g $GID || true) \
    && (useradd -Nlm $USER -g $GID -u $UID || true)

# Work around for https://github.com/nodejs/docker-node/issues/1013 (adapted from an example in the comments)
RUN echo "deb http://deb.debian.org/debian jessie main" > /etc/apt/sources.list
RUN echo "deb http://security.debian.org jessie/updates main" >> /etc/apt/sources.list
RUN apt-get update

# seems to be needed to properly install chromedriver
RUN apt-get install -y libnss3

# chrome - instructions from https://www.linuxbabe.com/desktop-linux/how-to-install-google-chrome-on-debian-the-easy-way
RUN curl -sL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y google-chrome-stable

# upgrade yarn version: from https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md#upgradingdowngrading-yarn
ENV YARN_VERSION 1.15.2
RUN curl -fSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
    && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
    && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
    && ln -snf /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
    && rm yarn-v$YARN_VERSION.tar.gz

USER <REDACTED>

As for #2154, I left a comment some weeks back here, but I'm happy to add more to it if you feel like that's useful :)

For more notes on reproduction, I've seen tests work when we run just one on our local machines (latest MacOS). I suspect it needs to have something long-running enough to trigger the issue, but I don't make this claim with certainty. Of course as I find out more I'll chime in.

@lajuffermans
Copy link

Same issue here since we migrated from nightwatch 0.9.20 to 1.3.6 and it doesn't always happen:

  • node: 10.21.0
  • nigthwatch: 1.3.6
  • chromedriver: 83.0.0
An error occurred while retrieving a new session: "socket hang up"

      Error: An error occurred while retrieving a new session: &#34;socket hang up&#34;
    at Selenium2Protocol.handleSessionCreateError 
    at HttpRequest.request.on.err 
    at emitOne (events.js:116:13)
    at HttpRequest.emit (events.js:211:7)
    at ClientRequest.originalIssuer.on.args 
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketCloseListener (_http_client.js:377:9)
    at emitOne (events.js:121:20)
    at Socket.emit (events.js:211:7)

marian-r added a commit to marian-r/nightwatch that referenced this issue Jul 18, 2020
- fixed handling of sesion creation errors during test case run to be reported as test errors
- fixed retries for session creation - errors are now reported only after retry limit is reached
@marian-r
Copy link
Contributor

I think I've found the root cause and created #2455 to fix it.

I've discovered that the error occurs after the request for creating session times out. This case is handled properly at the test suite start, but not for during individual tests. If one test closes session using client.end() it has to be recreated at the beginning of another test. If the request times out there, error is unhandled and may result in tests not starting and/or being not reported as failed.

@Pieras2
Copy link

Pieras2 commented Aug 10, 2020

Which NW version will carry the fix?
I get the socket hangups on AzureDevops - on NW 1.3.4 on chrome (84), while with NW 1.3.7 more often on firefox :/

@drabelo
Copy link

drabelo commented Aug 25, 2020

Is this issue being addressed?

@RichMatthews
Copy link

I'm getting this issue too, would be good to know if it's getting progressed

@beatfactor
Copy link
Member

Yes, a fix will be released in the next version, which is already in master and should be available in NPM by early next week.

@Pieras2
Copy link

Pieras2 commented Aug 27, 2020 via email

@drabelo
Copy link

drabelo commented Aug 27, 2020

Perfect! Thank you :) 🙏

@RichMatthews
Copy link

@beatfactor do you know if this is now fixed and what version of Nightwatch we should upgrade to?

@beatfactor
Copy link
Member

beatfactor commented Sep 4, 2020 via email

@shreev1
Copy link

shreev1 commented Oct 21, 2020

this issue is there in 1.3.6 and 1.4.3 while not in 0.9.12 (that is quiet old version to use)
Please advise

@Pieras2
Copy link

Pieras2 commented Oct 22, 2020

unfortunately I switched to 1.4.3 counting that no more hangup will happen on Azure devops but unfortunately I caught it too :(

@beatfactor
Copy link
Member

this issue is there in 1.3.6 and 1.4.3 while not in 0.9.12 (that is quiet old version to use)
Please advise

@shreev1 Can you elaborate on the kind of errors you have been seeing? Have you set timeout_options to retry the aborted http requests – this doesn't happen by default, maybe we'll add retries as default in future versions..

@VikasGhorpade
Copy link

VikasGhorpade commented Oct 28, 2020

I am also facing same issue like socket hang up error:
POST /wd/hub/session/685536c4130398c484012ff61549e6bf/elements - ECONNRESET
Error: socket hang up
at createHangUpError (_http_client.js:342:15)
at Socket.socketOnEnd (_http_client.js:437:23)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
Error while running .locateMultipleElements() protocol action: An unknown error has occurred.

I tested with nightwatch 1.3.6, 1.4.3 and 1.5.0 as well but issue is still reproducible and it appears in between execution of tests in parallel.
I tried by increasing the request_timeout_option as well but did not help:
"request_timeout_options": {
"timeout": 120000
},

in which version this issue will be fixed?

@kretschmannj
Copy link

kretschmannj commented Dec 28, 2020

I also get this error when running in parallel. Last update was two months ago. Any update?

@theLopesPG
Copy link

Having the same error on 1.5.1

@kretschmannj
Copy link

I had this problem consistently when attempting to run tests in parallel and was able to resolve the issue by adding this to my test_settings ...

    default: {
      request_timeout_options: { // configure when should a request to the Selenium server reach a timeout and optionally define the number of retries for a timed out request
        timeout: 100000,
        retry_attempts: 3
      },
    },

@lxblvs
Copy link

lxblvs commented Mar 23, 2021

UPD: looks like the problem occurs due to me using chromium

Running on Ubuntu

Nightwatch:
    version: 1.5.1

nightwatch.json directly from the documentation:

{
  "src_folders" : ["tests"],

  "webdriver" : {
    "start_process": true,
    "server_path": "node_modules/.bin/chromedriver",
    "port": 9515
  },

  "test_settings" : {
    "default" : {
      "desiredCapabilities": {
        "browserName": "chrome"
      }
    }
  }
}

package.json :

{
  "devDependencies": {
    "chromedriver": "^89.0.0",
    "nightwatch": "^1.5.1"
  }
}

Running:

Nightwatch nightwatch --verbose
 Starting ChromeDriver on port 9515...
 ChromeDriver up and running on port 9515 with pid: 100530 (118ms).

[Happy Path] Test Suite
=======================
⠋ Connecting to localhost on port 9515...
   Request POST  /session  
⠦ Connecting to localhost on port 9515...
    POST  /session - ECONNRESET
⚠ Error connecting to localhost on port 9515.
_________________________________________________

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (1m 0s)

 ✖ happy_path
   An error occurred while retrieving a new session: "socket hang up"
Error: An error occurred while retrieving a new session: "socket hang up"

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

   SKIPPED:
   - The Path

@wegry
Copy link

wegry commented May 12, 2021

Seeing this bumping from nightwatch@1.6.3 to 1.6.4. with Node 14.16.0.

ℹ Connected to localhost on port 9515 (311ms).
  Using: chrome (90.0.4430.93) on Mac OS X platform.

    POST  /session/463b3862e24d48054968692a3565fd66/url - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:607:14)
 Error while running .navigateTo() protocol action: Error ECONNRESET: socket hang up

    POST  /session/463b3862e24d48054968692a3565fd66/elements - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:607:14)
 Error while running .locateMultipleElements() protocol action: Error ECONNRESET: socket hang up

@beatfactor
Copy link
Member

@wegry can you open a new issue please?

@wegry
Copy link

wegry commented May 12, 2021

@beatfactor after trying again with the latest Node LTS (14.17.0), I was unable to repro on two subsequent runs. If I run into it again, I'll open an issue.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

@stale stale bot added the stale label Apr 16, 2022
@stale stale bot closed this as completed Apr 29, 2022
@s9tpepper
Copy link

s9tpepper commented Jul 29, 2022

Still seeing this issue with Nightwatch 2.3.0 with Chromedriver 103 and Chrome 103 running on node 14.18.1

⠸ Starting ChromeDriver on port 9515...
    GET  /session/7c6316a4600a4833738e875e14b51041/element/58ae2e19-3b4e-4572-a13e-cd1d7c4656dc/text - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at endReadableNT (internal/streams/readable.js:1334:12)
    GET  /session/7c6316a4600a4833738e875e14b51041/element/58ae2e19-3b4e-4572-a13e-cd1d7c4656dc/name - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at endReadableNT (internal/streams/readable.js:1334:12)
    GET  /session/7c6316a4600a4833738e875e14b51041/element/58ae2e19-3b4e-4572-a13e-cd1d7c4656dc/name - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at endReadableNT (internal/streams/readable.js:1334:12)
    GET  /session/7c6316a4600a4833738e875e14b51041/element/3ca3a403-371b-4aec-8f9c-9bdd99b55488/attribute/href - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
    at endReadableNT (internal/streams/readable.js:1334:12)
    POST  /session - ECONNRESET
Error: socket hang up
    at connResetException (internal/errors.js:639:14)
⠼ Starting ChromeDriver on port 9515...
 Error while running .getElementTagName() protocol action: invalid session id


───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  TEST FAILURE (12.461s): 
   - 1 error during execution; 
   - 0 tests failed; 
   - 0/NA tests passed



 TypeError: Cannot read property 'toLowerCase' of null

@gravityvi
Copy link
Member

Hey @s9tpepper can you raise another issue regarding this if you are still facing problems related to chromedriver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests