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: runIfWaitingForDebugger when targets are reloaded after crashing #28254

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 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,12 @@ export class BrowserCriClient {
this._onTargetDestroyed({ browserClient, browserCriClient, browserName, event, onAsynchronousError })
})

browserClient.on('Inspector.targetReloadedAfterCrash', async (event, sessionId) => {
// 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)
})

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)
},
})
})