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

Restore just-in-time require/require splitting in cypress.js #21236

Closed
flotwig opened this issue Apr 27, 2022 · 2 comments
Closed

Restore just-in-time require/require splitting in cypress.js #21236

flotwig opened this issue Apr 27, 2022 · 2 comments
Assignees

Comments

@flotwig
Copy link
Contributor

flotwig commented Apr 27, 2022

See #21174 for context.

We should remove these lines:

// We require project-base here, as waiting to require it in
// the Electron process for the first time can cause the process
// to hang during smoke test execution. This occurs with Electron
// version v15.4.0 and after.
//
// TODO: Investigate need/removal of this with future major versions
// of Electron when upgraded: https://github.com/cypress-io/cypress/pull/19090
require('@packages/server/lib/project-base')

Because cypress.js should not be slowed down by unused code:

// we are not requiring everything up front
// to optimize how quickly electron boots while
// in dev or linux production. the reasoning is
// that we likely may need to spawn a new child process
// and its a huge waste of time (about 1.5secs) of
// synchronous requires the first go around just to
// essentially do it all again when we boot the correct
// mode.

Or, remove the need for cypress.js to ever run in node.

Once cypress.js's JIT requires are restored, we can clean up these areas:

  • No longer will need to JIT require here, since we will no longer be requiring makeDataContext outside of electron:
    },
    showItemInFolder (folder: string) {
    require('electron').shell.showItemInFolder(folder)
    },
    showOpenDialog (props: OpenDialogOptions) {
    return require('electron').dialog.showOpenDialog(props)
    },
    showSaveDialog (window: BrowserWindow, props: SaveDialogOptions) {
    return require('electron').dialog.showSaveDialog(window, props)
    },
    copyTextToClipboard (text: string) {
    require('electron').clipboard.writeText(text)
    },
    isMainWindowFocused () {
    return Windows.isMainWindowFocused()
    },
    focusMainWindow () {
    return Windows.focusMainWindow()
    },
  • Any other areas where we currently have to JIT require to avoid triggering errors related to electron not being available.
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 19, 2022

The code for this is done in cypress-io/cypress#21541, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@flotwig flotwig closed this as completed May 19, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 1, 2022

Released in 10.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants