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

[🐛 Bug]: Error when using different node versions #10970

Closed
TamsilAmani opened this issue Aug 22, 2022 · 7 comments
Closed

[🐛 Bug]: Error when using different node versions #10970

TamsilAmani opened this issue Aug 22, 2022 · 7 comments
Assignees

Comments

@TamsilAmani
Copy link
Contributor

What happened?

Issue 1 is based on nightwatchjs/nightwatch#3337

ISSUE 1:
On node v10 (10.24.1), when I run the selenium code, I get the error SyntaxError: Unexpected token = in file virtual_authenticator.js. The same script runs without any error in v12 (12.22.12).
I am not able to test it on v11.

ISSUE 2:
There is another issue which occurs in the same selenium code. On node v18 (18.7.0) the code is not able to start geckodriver and it gives the error Error: Timed out waiting for the WebDriver server at http://localhost:51846/. The same code works without any error (i.e. it starts the geckodriver) in v16 (16.16.0)

This looks like some version problem with nodejs. I'm troubleshooting it from my end. Any leads would be helpful.
CC: @harsha509

How can we reproduce the issue?

Step 1: Set your nodejs version with your version manager. I use nvm.
Step 2: Run the following selenium code.

const {Builder} = require('selenium-webdriver');

(async function helloSelenium() {
    let driver = await new Builder().forBrowser('firefox').build();

    await driver.get('https://selenium.dev');

    await driver.quit();
})();

Relevant log output

ISSUE 1:

/Users/tamsilamani/Desktop/BrowserStack/seleniumhq.github.io/examples/javascript/node_modules/selenium-webdriver/lib/virtual_authenticator.js:26
  Protocol = {
           ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/tamsilamani/Desktop/BrowserStack/seleniumhq.github.io/examples/javascript/node_modules/selenium-webdriver/lib/webdriver.js:40:20)



ISSUE 2:

/Users/tamsilamani/Desktop/BrowserStack/seleniumhq.github.io/examples/javascript/node_modules/selenium-webdriver/http/util.js:88
        reject(Error('Timed out waiting for the WebDriver server at ' + url))
               ^

Error: Timed out waiting for the WebDriver server at http://localhost:51846/
    at onError (/Users/tamsilamani/Desktop/BrowserStack/seleniumhq.github.io/examples/javascript/node_modules/selenium-webdriver/http/util.js:88:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Operating System

macOS Monterey

Selenium version

Javascript 4.4.0

What are the browser(s) and version(s) where you see this issue?

Firefox 103.0.2

What are the browser driver(s) and version(s) where you see this issue?

GeckoDriver 0.31.0

Are you using Selenium Grid?

No response

@github-actions
Copy link

@TamsilAmani, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@pujagani pujagani assigned pujagani and TamsilAmani and unassigned pujagani Aug 22, 2022
@harsha509
Copy link
Member

HI @TamsilAmani ,

InstanceOf doesn't work as expected in node 18!

Ex: insatnceOf in ff createSession

I have a fix ready for Firefox issue as I rewrote firefox.js a bit

need to debug for virtual_authenticator.js with node 12 and node 14.

For JS we had version set for node 14 AFAIK!

@harsha509
Copy link
Member

Hi @TamsilAmani,

About issue 1,

I don't think we should support node 10. It is deprecated long ago and selenium-webdriver should target LTS and stable version and <LTS should be mostly unsupported!

@TamsilAmani
Copy link
Contributor Author

Thank you for the commit. On issue 1, I agree with you on that @harsha509.

@TamsilAmani
Copy link
Contributor Author

ISSUE 1 is occuring because:

  1. In commit 1c2240d, in file virtual_authenticator.js, at line

    class VirtualAuthenticatorOptions {
    static Protocol = {
    "CTAP2": 'ctap2',
    "U2F": 'ctap1/u2f',
    }
    static Transport = {
    "BLE": 'ble',
    "USB": 'usb',
    "NFC": 'nfc',
    "INTERNAL": 'internal',
    }
    , declares Protocol and Transport as static and within the class. Maybe node v10 does not support this approach.

  2. The solution which I found, and which is already merged, is in commit b8ede33, at

    const Protocol = {
    'CTAP2': 'ctap2',
    'U2F': 'ctap1/u2f',
    }
    /**
    * AuthenticatorTransport values
    * @enum {string}
    */
    const Transport = {
    'BLE': 'ble',
    'USB': 'usb',
    'NFC': 'nfc',
    'INTERNAL': 'internal',
    }
    /**
    * Options for the creation of virtual authenticators.
    * @see http://w3c.github.io/webauthn/#sctn-automation
    */
    class VirtualAuthenticatorOptions {
    , which makes Protocol and Transport const and also declares them outside the class.

Hence I believe we have to make a new release which includes commit mentioned on point (2) to solve for Issue 1 @AutomatedTester

@harsha509
Copy link
Member

As discussed, I've set the min node version to the least Maintainance LTS with security updates.
if the Current LTS is 16(N), Maintainance LTS with security updates will be N-2, and stable will be N+2

This change is done with commit 024d863 !

Closing this as all issues are resolved and fixes will be available in 4.5.0!

@github-actions
Copy link

github-actions bot commented Oct 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants