cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.06k stars 3.19k forks source link

Electron 29: Warning on 'Node.js environment variables are disabled because this process is invoked by other apps.' #30239

Closed jennifer-shehane closed 3 weeks ago

jennifer-shehane commented 2 months ago

What would you like?

Seeing this warning in Electron 29 tests here: https://app.circleci.com/pipelines/github/cypress-io/cypress/64069/workflows/1cbb1422-c586-4814-96a2-3414e0d7f397/jobs/2657028

[0913/132025.057522:ERROR:node_main.cc(145)] Node.js environment variables are disabled because this process is invoked by other apps.

This is due to a change in Electron 29 from this PR: https://github.com/electron/electron/pull/40579

    // On macOS, it is forbidden to run sandboxed app with custom arguments
    // from another app, i.e. args are discarded in following call:
    //   exec("Sandboxed.app", ["--custom-args-will-be-discarded"])
    // However it is possible to bypass the restriction by abusing the node mode
    // of Electron apps:
    //   exec("Electron.app", {env: {ELECTRON_RUN_AS_NODE: "1",
    //                               NODE_OPTIONS: "--require 'bad.js'"}})
    // To prevent Electron apps from being used to work around macOS security
    // restrictions, when NODE_OPTIONS is passed it will be checked whether
    // this process is invoked by its own app.
    if (!ProcessBelongToCurrentApp(getppid())) {
      LOG(ERROR) << "NODE_OPTIONS is disabled because this process is invoked "
                    "by other apps.";
      node_options_enabled = false;
    }
  }

This behavior was refined in Electron 30 here: https://github.com/electron/electron/pull/41079

Users will not like to see this error if this is present when running Cypress in Electron 29.

Why is this needed?

.

Other

No response

MikeMcC399 commented 2 months ago

https://github.com/electron/electron/pull/41079 was backported to Electron 29 in https://github.com/electron/electron/pull/41102 and is listed in the release notes for https://releases.electronjs.org/release/v29.0.0 so I imagine that Electron 30 will not be an improvement. Maybe worth testing with Electron 30 (or later) anyway?

jennifer-shehane commented 2 months ago

I suppose. Electron 29 will need to be a breaking change we've decided, so I guess we could try 30 while we're at it.

MikeMcC399 commented 1 month ago

@jennifer-shehane

Electron 29 will need to be a breaking change we've decided, so I guess we could try 30 while we're at it.