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

fix: issue with missing chrome browser instance during tests #26817

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/server/lib/browsers/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,17 @@ export = {
async connectToNewSpec (browser: Browser, options: BrowserNewTabOpts, automation: Automation) {
debug('connecting to new chrome tab in existing instance with url and debugging port', { url: options.url })

const browserCriClient = this._getBrowserCriClient()

if (!browserCriClient) throw new Error('Missing browserCriClient in connectToNewSpec')
let browserClient = this._getBrowserCriClient();

if (!browserClient) {
// create a new instance of the client in case something went wrong
// https://github.com/cypress-io/cypress/issues/24650
const port = await protocol.getRemoteDebuggingPort()
browserCriClient = await BrowserCriClient.create(['127.0.0.1'], port, browser.displayName, options.onError, onReconnect)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we use the same connection logic elsewhere I wonder if we can refactor this. @ryanthemanuel is this something we should be doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same. I kind of wanted to get some discussion on this so we could try and attempt to fix this issue which is causing us some major head-aches. I'm more than happy to contribute towards the fix if need be.

browserClient = browserCriClient;
}

const pageCriClient = browserCriClient.currentlyAttachedTarget
const pageCriClient = browserClient.currentlyAttachedTarget

if (!pageCriClient) throw new Error('Missing pageCriClient in connectToNewSpec')

Expand Down