Skip to content

Commit

Permalink
fix: runIfWaitingForDebugger when targets are reloaded after crashing (
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel committed Nov 7, 2023
1 parent e8fc268 commit d70ffea
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _Released 11/7/2023 (PENDING)_
- Fixed an issue with 'other' targets (e.g. pdf documents embedded in an object tag) not fully loading. Fixes [#28228](https://github.com/cypress-io/cypress/issues/28228) and [#28162](https://github.com/cypress-io/cypress/issues/28162).
- Fixed an issue where network requests made from tabs/windows other than the main Cypress tab would be delayed. Fixes [#28113](https://github.com/cypress-io/cypress/issues/28113).
- Stopped processing CDP events at the end of a spec when Test Isolation is off and Test Replay is enabled. Addressed in [#28213](https://github.com/cypress-io/cypress/pull/28213).
- Fixed a regression in [`13.3.3`](https://docs.cypress.io/guides/references/changelog/13.3.3) where Cypress would hang on loading shared workers when using `cy.reload` to reload the page. Fixes [#28248](https://github.com/cypress-io/cypress/issues/28248).

## 13.4.0

Expand Down
11 changes: 11 additions & 0 deletions packages/server/lib/browsers/browser-cri-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ export class BrowserCriClient {
this._onTargetDestroyed({ browserClient, browserCriClient, browserName, event, onAsynchronousError })
})

browserClient.on('Inspector.targetReloadedAfterCrash', async (event, sessionId) => {
try {
// Things like service workers will effectively crash in terms of CDP when the page is reloaded in the middle of things
// We will still auto attach in this case, but we need to runIfWaitingForDebugger to get the page back to a running state
await browserClient.send('Runtime.runIfWaitingForDebugger', undefined, sessionId)
} catch (error) {
// it's possible that the target was closed before we can run. If so, just ignore
debug('error running Runtime.runIfWaitingForDebugger:', error)
}
})

await Promise.all(promises)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/browsers/cdp_automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const normalizeResourceType = (resourceType: string | undefined): Resourc

export type SendDebuggerCommand = <T extends CdpCommand>(message: T, data?: ProtocolMapping.Commands[T]['paramsType'][0], sessionId?: string) => Promise<ProtocolMapping.Commands[T]['returnType']>

export type OnFn = <T extends CdpEvent>(eventName: T, cb: (data: ProtocolMapping.Events[T][0]) => void) => void
export type OnFn = <T extends CdpEvent>(eventName: T, cb: (data: ProtocolMapping.Events[T][0], sessionId?: string) => void) => void

export type OffFn = (eventName: string, cb: (data: any) => void) => void

Expand Down
9 changes: 9 additions & 0 deletions system-tests/projects/e2e/cypress/e2e/web_worker.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ it('loads web workers', { defaultCommandTimeout: 1900 }, () => {
.then(webWorker)
.then(sharedWorker)
})

// Timeout of 1900 will ensure that the proxy correlation timeout is not hit
it('reloads web workers', { defaultCommandTimeout: 1900 }, () => {
cy.visit('https://localhost:1515/web_worker.html')

cy.reload()
.then(webWorker)
.then(sharedWorker)
})
4 changes: 2 additions & 2 deletions system-tests/test/web_worker_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('e2e web worker', () => {
spec: 'web_worker.cy.js',
onRun: async (exec, browser) => {
await exec()
expect(requestsForWebWorker).to.eq(1)
expect(requestsForSharedWorker).to.eq(1)
expect(requestsForWebWorker).to.eq(2)
expect(requestsForSharedWorker).to.eq(2)
},
})
})

5 comments on commit d70ffea

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d70ffea Nov 7, 2023

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 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.4.1/linux-arm64/develop-d70ffea0bf0d5df72a949c7d1a44030f4b39dec1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d70ffea Nov 7, 2023

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.4.1/linux-x64/develop-d70ffea0bf0d5df72a949c7d1a44030f4b39dec1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d70ffea Nov 7, 2023

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.4.1/darwin-x64/develop-d70ffea0bf0d5df72a949c7d1a44030f4b39dec1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d70ffea Nov 7, 2023

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.4.1/darwin-arm64/develop-d70ffea0bf0d5df72a949c7d1a44030f4b39dec1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d70ffea Nov 7, 2023

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.5.0/win32-x64/develop-d70ffea0bf0d5df72a949c7d1a44030f4b39dec1/cypress.tgz

Please sign in to comment.