Skip to content

Commit

Permalink
chore: add graphql schema update and wrap process.kill to swallow esr…
Browse files Browse the repository at this point in the history
…ch error [run ci] (#30434)
  • Loading branch information
AtofStryker authored Oct 21, 2024
1 parent e0177ff commit aafac6a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ enum ErrorTypeEnum {
EXPERIMENTAL_STUDIO_REMOVED
EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY
EXTENSION_NOT_LOADED
FIREFOX_CDP_FAILED_TO_CONNECT
FIREFOX_COULD_NOT_CONNECT
FIREFOX_GC_INTERVAL_REMOVED
FIREFOX_GECKODRIVER_FAILURE
Expand Down
26 changes: 24 additions & 2 deletions packages/server/lib/browsers/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,36 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
// now that we have the driverPID and browser PID
browserInstanceWrapper.kill = (...args) => {
// Do nothing on failure here since we're shutting down anyway

clearInstanceState({ gracefulShutdown: true })

debug('closing firefox')

const browserReturnStatus = process.kill(browserPID)
let browserReturnStatus = true

try {
browserReturnStatus = process.kill(browserPID)
} catch (e) {
if (e.code === 'ESRCH') {
debugVerbose('browser process no longer exists. continuing...')
} else {
throw e
}
}

debug('closing geckodriver and webdriver')
const driverReturnStatus = process.kill(driverPID)

let driverReturnStatus = true

try {
driverReturnStatus = process.kill(driverPID)
} catch (e) {
if (e.code === 'ESRCH') {
debugVerbose('geckodriver/webdriver process no longer exists. continuing...')
} else {
throw e
}
}

// needed for closing the browser when switching browsers in open mode to signal
// the browser is done closing
Expand Down
20 changes: 20 additions & 0 deletions packages/server/test/unit/browsers/firefox_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,26 @@ describe('lib/browsers/firefox', () => {
expect(instance.emit).to.have.been.calledWith('exit')
})

it('swallows ESRCH in kill method if thrown', async function () {
const ESRCHErr: Error & { code?: string } = new Error('BOOM')

ESRCHErr.code = 'ESRCH'
sinon.stub(process, 'kill').throws(ESRCHErr)
const instance = await firefox.open(this.browser, 'http://', this.options, this.automation)

sinon.spy(instance, 'emit')
const killResult = instance.kill()

expect(killResult).to.be.true
// kills the browser
expect(process.kill).to.have.been.calledWith(1234)
// kills the webdriver process/ geckodriver process
expect(process.kill).to.have.been.calledWith(5678)
expect(browserCriClient.close).to.have.been.called
// makes sure the exit event is called to signal to the rest of cypress server that the processes are killed
expect(instance.emit).to.have.been.calledWith('exit')
})

it('throws CDPFailedToStartFirefox if the mox:debuggerAddress capability is not returned by webdriver', function () {
delete wdInstance.capabilities['moz:debuggerAddress']
sinon.stub(process, 'kill').returns(true)
Expand Down

4 comments on commit aafac6a

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on aafac6a Oct 21, 2024

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/linux-x64/develop-aafac6a6104b689a118f4c4f29f948d7d8a35aef/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on aafac6a Oct 21, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-arm64/develop-aafac6a6104b689a118f4c4f29f948d7d8a35aef/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on aafac6a Oct 21, 2024

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/win32-x64/develop-aafac6a6104b689a118f4c4f29f948d7d8a35aef/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on aafac6a Oct 21, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.15.1/darwin-x64/develop-aafac6a6104b689a118f4c4f29f948d7d8a35aef/cypress.tgz

Please sign in to comment.