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

[💡 Feature]: Support configuring NODE_OPTIONS for ChromeDriver separately from NODE_OPTIONS for WDIO itself #12753

Open
1 task done
tanin47 opened this issue Apr 25, 2024 · 5 comments
Labels
help wanted Issues that are free to take by anyone interested Idea 💡 A new feature idea

Comments

@tanin47
Copy link

tanin47 commented Apr 25, 2024

Is your feature request related to a problem?

Here's the background: webdriverio-community/wdio-electron-service#331

tldr: we were stuck in getting Electron (dev mode, not prod) to start within WDIO. We've figured that the root cause is because NODE_OPTIONS was set on ChromeDriver. The NODE_OPTIONS (intended for WDIO) happens to cause issue in Electron.

Specifically, WDIO sets NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' (ref), which is carried over to ChromeDriver and, thus, Electron.

To verify the impact of this env, we can run: NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' ./node_modules/.bin/electron in Terminal, and Electron will crash.

Describe the solution you'd like.

We want to be able to to configure NODE_OPTIONS for ChromeDriver separately from the NODE_OPTIONS for WDIO.

Today NODE_OPTIONS for WDIO is carried over to ChromeDriver; in turn, it is carried over to Electron (dev mode), and Electron crashes because of it.

Here's the line that we want to inject NODE_OPTIONS only for ChromeDriver: https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-utils/src/node/startWebDriver.ts#L86

We want to change it to something like:

driverProcess = cp.spawn(chromedriverExcecuteablePath, driverParams, { env: {...process.env, NODE_OPTIONS: configured_node_options } })

I would also consider adding shell: true, so it closely resembles when the Electron is started directly from command line.

Describe alternatives you've considered.

We could just filter out NODE_OPTIONS altogether as well like:

driverProcess = cp.spawn(chromedriverExcecuteablePath, driverParams, { env: { ...process.env, NODE_OPTIONS: null } })

This also might be preferable because it's more minimal, and we currently don't have a reason to set NODE_OPTIONS for ChromeDriver/Electron.

Additional context

We are trying to get wdio-electron-service to support testing against Electron (dev mode), not just prod mode.

Electron (prod mode) doesn't have the same problem because the prod mode forbids NODE_OPTIONS (ref).

cc @goosewobbler @christian-bromann

Code of Conduct

  • I agree to follow this project's Code of Conduct
@tanin47 tanin47 added Idea 💡 A new feature idea Needs Triaging ⏳ No one has looked into the issue yet labels Apr 25, 2024
@christian-bromann
Copy link
Member

Today NODE_OPTIONS for WDIO is carried over to ChromeDriver; in turn, it is carried over to Electron (dev mode), and Electron crashes because of it.

Can you be more specific on this section? I don't quite get why certain environment variables available when starting Chromedriver cause Electron to crash.

I would also consider adding shell: true, so it closely resembles when the Electron is started directly from command line.

How is starting Electron related to starting Chromedriver?

@tanin47
Copy link
Author

tanin47 commented Apr 26, 2024

Thank you.

How is starting Electron related to starting Chromedriver?

ChromeDriver starts Electron, and I think the shell env is likely carried over to Electron when ChromeDriver starts Electron, but I don't have a way to confirm this.

I also added in the below to the post:

Specifically, WDIO sets NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' (ref), which is carried over to ChromeDriver and, thus, Electron.

To verify the impact of this env, we can run: NODE_OPTIONS=' --loader ts-node/esm/transpile-only --no-warnings' ./node_modules/.bin/electron in Terminal, and Electron will crash.

@christian-bromann
Copy link
Member

Thanks for clarifying! I think the best solution would be to just filter out NODE_OPTIONS as you mentioned in your alternative approach. Until we don't really have a reason why someone would need to control extra env vars for Chrome/Electron we shouldn't add any complexity.

Any contributions would be appreciated.

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 26, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

@tanin47
Copy link
Author

tanin47 commented Apr 27, 2024

Sounds good. I'm happy to make the change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are free to take by anyone interested Idea 💡 A new feature idea
Projects
None yet
Development

No branches or pull requests

3 participants