webdriverio / selenium-standalone

A Node.js based package and CLI library for launching Selenium with WebDrivers support (Chrome, Firefox, IE, Edge)
https://webdriver.io
Other
910 stars 222 forks source link

Selenium exited before it could start with code 1 #788

Closed thepassle closed 1 year ago

thepassle commented 1 year ago

Expected Behavior

Selenium starts the process as expected and does not exit before it can start

Current Behavior

Selenium exits before it can start without a clear error message (no stdout or stderr)

Steps to Reproduce

Provide an unambiguous set of steps to reproduce this bug. Include commands that you used in the shell, or snippets of how you are using the JavaScript API.

  1. npm init --y && npm i -S selenium-standalone
  2. Set "type": "module" in the package.json
  3. touch index.js
  4. Add the following code to index.js:
    
    import selenium from 'selenium-standalone';

await selenium.install({ drivers: { chrome: { version: 'latest' }, firefox: { version: 'latest' }, }, });

await selenium.start({ drivers: { chrome: { version: 'latest' }, firefox: { version: 'latest' }, }, seleniumArgs: ['--port', '8888'], });


5.  run `node index.js`

<img width="1063" alt="image" src="https://github.com/webdriverio/selenium-standalone/assets/17054057/d2a5e900-09ee-4d1d-bf89-424babd4c5d9">

## Logs
It is helpful to include any logs that selenium-standalone outputs to help diagnose issues.
Take a look at the [README](https://github.com/webdriverio/selenium-standalone/blob/main/README.md#debug-logs-for-selenium-standalone-process) for how
to enable debug log statements that will help us even more than the standard output logs.

If there are lots of logs, please link to [a public gist](https://gist.github.com/).

## Your Environment
* Version of `selenium-standalone` that you are using: 8.3.0
* Is there another tool calling `selenium-standalone` on your behalf: no
* System/platform: macos
* Other details that might be important:
christian-bromann commented 1 year ago

Thanks for reporting!

It seems like the binary is unable to start, can you check if you can start the JAR file, stored in /node_modules/selenium-standalone directly?

Any contributions that resolves the bug are highly appreciated. Don't expect this to be picked up by active contributors as they have their own priorities. If you depend on this bug to be fixed, your contribution is required. Please take a look into our contribution guidelines or join our Discord development server and let us know if you have any questions. Cheers!

thepassle commented 1 year ago

It seems like the binary is unable to start, can you check if you can start the JAR file, stored in /node_modules/selenium-standalone directly?

Im not really sure what the expected behavior is, but opening the JAR file in node_modules/selenium-standalone/.selenium/selenium-server/4.4.0/selenium-server.jar doesnt seem to do anything. I dont see any errors, I don't see any new processes started in my activity monitor, it just seems to do nothing 😅

thepassle commented 1 year ago

I came back to this, without reinstalling or anything, and today I'm getting:

⚡ node index.js
Failed to connect to selenium. Attempts left: 115 
 connect ECONNREFUSED 127.0.0.1:8888

running the exact same repo I used and posted above here. The impact of these errors/this package breaking is that the tests of our master branch on https://github.com/modernweb-dev/web seemingly randomly started failing (by breaking at least three of our packages), and we're not sure how to solve this.

Any contributions that resolves the bug are highly appreciated. Don't expect this to be picked up by active contributors as they have their own priorities. If you depend on this bug to be fixed, your contribution is required. Please take a look into our contribution guidelines or join our Discord development server and let us know if you have any questions. Cheers!

As an open source maintainer myself, I understand this sentiment, but unfortunately it's not very helpful in this situation. Seemingly some kind of JAR file shipped in an NPM package is broken, and it's broken the main export of this project. I'd normally be happy to dive in, debug an issue in JS code, and create a PR with a fix, but I have no clue where to begin debugging a shipped binary.

christian-bromann commented 1 year ago

I am happy to take a look this week.

e-e-e commented 1 year ago

I am experiencing this issue as well - if i start in watch mode it will wait until the selenium server has started and work as expected:

2023-05-26T01:37:43.959Z INFO @wdio/cli:launcher: Run onPrepare hook
Failed to connect to selenium. Attempts left: 115

Failed to connect to selenium. Attempts left: 110

2023-05-26T01:37:52.863Z INFO @wdio/cli:launcher: Run onWorkerStart hook

It looks like when running outside of watch mode its just not waiting for selenium to start up.

If helpful - I am running a Apple M1 Pro with OS Version 13.2.1 (22D68).

nikhil-sharma10 commented 1 year ago

@christian-bromann Recently I have seen that for Chrome 115 version google has updated the end-point for finding the Chrome driver binary, which is actually causing us to not be able to provide any specific Chrome driver version in the selenium-standalone service. If you see selenium-standalone service hit https://chromedriver.storage.googleapis.com/ end-point to get the required chrome driver, but now since this change, version 115 isn't present here. All the details are mentioned https://googlechromelabs.github.io/chrome-for-testing/ , https://chromedriver.chromium.org/downloads. Are we going to do anything about it?

udarrr commented 1 year ago

I came back to this, without reinstalling or anything, and today I'm getting:

⚡ node index.js
Failed to connect to selenium. Attempts left: 115 
 connect ECONNREFUSED 127.0.0.1:8888

running the exact same repo I used and posted above here. The impact of these errors/this package breaking is that the tests of our master branch on https://github.com/modernweb-dev/web seemingly randomly started failing (by breaking at least three of our packages), and we're not sure how to solve this.

Any contributions that resolves the bug are highly appreciated. Don't expect this to be picked up by active contributors as they have their own priorities. If you depend on this bug to be fixed, your contribution is required. Please take a look into our contribution guidelines or join our Discord development server and let us know if you have any questions. Cheers!

As an open source maintainer myself, I understand this sentiment, but unfortunately it's not very helpful in this situation. Seemingly some kind of JAR file shipped in an NPM package is broken, and it's broken the main export of this project. I'd normally be happy to dive in, debug an issue in JS code, and create a PR with a fix, but I have no clue where to begin debugging a shipped binary.

I think the issue because your file wasn't downloaded properly. The tool just check existent of files but don't check their sizes and hash. That's why i assume you maybe downloaded selenium-server jar file on half of it real size for some reason. And obviously it's damaged, but selenium-standalone watch file existence and think everything all right. It can't be reinstalled automatically also, just after deletion. I had deal with the bug, and it was quite unpleasant have the kind of behavior. I've increased timeout for downloading because of that recently. From 90000 to 320000. But better here should be some kind of additional checks.

udarrr commented 1 year ago

resolved in https://github.com/webdriverio/selenium-standalone/pull/851