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

Impossible to set --proxy-bypass-list via ELECTRON_EXTRA_LAUNCH_ARGS #21172

Closed
sceee opened this issue Apr 22, 2022 · 10 comments
Closed

Impossible to set --proxy-bypass-list via ELECTRON_EXTRA_LAUNCH_ARGS #21172

sceee opened this issue Apr 22, 2022 · 10 comments
Assignees

Comments

@sceee
Copy link

sceee commented Apr 22, 2022

Current behavior

Inspired by #2374 (comment) to work around #2374, I am trying to set ELECTRON_EXTRA_LAUNCH_ARGS to --proxy-bypass-list=<-loopback>,localhost:8080.

Unfortunately, I can not get it to work for Electron, setting this for Chrome works through the before:browsers:launch hook but for Electron, I cannot get it working through the ELECTRON_EXTRA_LAUNCH_ARGS environment variable no matter what I try.

Desired behavior

I can set --proxy-bypass-list via ELECTRON_EXTRA_LAUNCH_ARGS to <-loopback>,localhost:8080.

Test code to reproduce

I tried to set ELECTRON_EXTRA_LAUNCH_ARGS to --proxy-bypass-list=<-loopback>,localhost:8080 the following ways:

  • Using set ELECTRON_EXTRA_LAUNCH_ARGS="--proxy-bypass-list=<-loopback>,localhost:8080" on Windows as described here in the docs
  • Adding it to the launchOptions equal and similar as I am doing it for Chrome
on('before:browser:launch', (browser = {}, launchOptions) => {
    if (browser.family === 'chromium' && browser.name !== 'electron') {
      launchOptions.args.push('--proxy-bypass-list=<-loopback>,localhost:8080')
    }
    if (browser.name === 'electron') {
      // Test possibly different syntax
      launchOptions.args['proxy-bypass-list'] = '<-loopback>,localhost:8080'
      launchOptions.args['--proxy-bypass-list'] = '<-loopback>,localhost:8080'
    }
    return launchOptions
  })
  • Setting it via cross-env in the npm script starting cypress: cross-env ELECTRON_EXTRA_LAUNCH_ARGS=\"--proxy-bypass-list=<-loopback>,localhost:8080\" cypress open

Unfortunately, none of those and no combination of those worked even though since #8001 (see https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/environment.js#L85), key-value pairs should also be supported and are also mentioned here #8399 (comment) .

The electron switch is documented here https://www.electronjs.org/de/docs/latest/api/command-line-switches#--proxy-bypass-listhosts .

Cypress Version

9.5.4

Other

No response

@github-actions
Copy link
Contributor

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@github-actions github-actions bot added the stale no activity on this issue for a long period label May 12, 2023
@sceee
Copy link
Author

sceee commented May 13, 2023

As far as it seems, this is still an issue in cypress 12.11.0.

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label May 15, 2023
@hongdeyuan
Copy link

hongdeyuan commented Jun 13, 2023

@sceee Can you try it?

like this:

docker run \
        --rm \
        --network ${NETWORK} \
        -v $WORKSPACE:/code \
        -w /code \
        -e ELECTRON_EXTRA_LAUNCH_ARGS="--proxy-bypass-list=<-loopback>,localhost:8080" \ # here add it
        ${CYPRESS_IMAGE}  --browser electron --headless

@sceee
Copy link
Author

sceee commented Jun 18, 2023

@hongdeyuan what's the difference in your command line than what I described above that does not work (besides the fact that you are using docker what I am not)?
This issue is about the fact that setting ELECTRON_EXTRA_LAUNCH_ARGS does not work as intended. Does it work for you to make the proxy bypass the mentioned connections using that command line?

@hongdeyuan
Copy link

hongdeyuan commented Jun 19, 2023

@hongdeyuan what's the difference in your command line than what I described above that does not work (besides the fact that you are using docker what I am not)? This issue is about the fact that setting ELECTRON_EXTRA_LAUNCH_ARGS does not work as intended. Does it work for you to make the proxy bypass the mentioned connections using that command line?

Oh, I thought it was using Docker; If you are not using Docker, you can try the following actions:
From the environment.js logic of cypress, ELECTRON_ EXTRA_ LAUNCH_ ARGS can only be transmitted through Export; This method is ineffective :
launchOptions.args['--proxy-bypass-list'] = '<-loopback>,localhost:8080'

You can do this: Running on your machine

  • Linux/OSX
    • export ELECTRON_EXTRA_LAUNCH_ARGS=--proxy-bypass-list=<-loopback>,localhost:8080
  • Windows
    • set ELECTRON_EXTRA_LAUNCH_ARGS=--proxy-bypass-list=<-loopback>,localhost:8080

@sceee
Copy link
Author

sceee commented Jun 21, 2023

@hongdeyuan thanks but this also does not seem to be working as written in the original issue. Additionally, I just reconfirmed it does not work.

@hongdeyuan
Copy link

@hongdeyuan thanks but this also does not seem to be working as written in the original issue. Additionally, I just reconfirmed it does not work.

inconceivable 🤔️, from the perspective of chromium-command-line-switches, it supports setting --proxy-bypass-list

@mike-plummer
Copy link
Contributor

@sceee If you can provide a reproduction case demonstrating this issue in action (ideally a git repo I can clone and run) I'd be happy to take a look at what's going on the with the environment parsing. I'm not familiar with setup/behavior of Electron proxy so a "do this, see that" example would be very helpful.

Before digging too far into this I will point out that the Electron docs use a semicolon ; as a separator/delimiter for that param value but you're using a comma ,- can you confirm this isn't a silly comma vs semicolon issue?

@sceee
Copy link
Author

sceee commented Jun 29, 2023

@mike-plummer I just confirmed it does also not work using semicolon ; as delimiter instead of comma ,.

Actually I moved a long time ago away from trying to use Electron and instead use Chrome as for Chrome, I can just use

on('before:browser:launch', (browser, launchOptions) => {
    ...
    launchOptions.args.push('--proxy-bypass-list=<-loopback>,localhost:5001,localhost:5002')
    ...
})

in cypress config and it just works. Creating a repro is unfortunately not that easy as Firestore emulator is involved. The issue that is hitting here is #2374 . Using Chrome with that proxy-bypass-list config works but Electron just can't establish connections to Firestore as the Firestore connection channel seems to be intercepted by Cypress.

@mike-plummer
Copy link
Contributor

@sceee Thanks for the extra context and workaround, glad you got something working for your use case. I'm going to go ahead and close this issue, but if anyone can provide a reproduction case we can reopen and investigate.

@mike-plummer mike-plummer closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants