Skip to content

Commit

Permalink
exit gracefully on webdriver crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirlucas committed Jan 15, 2025
1 parent 3bcb162 commit 69299a2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/browser/src/node/providers/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class WebdriverBrowserProvider implements BrowserProvider {
}
}

async openBrowser() {
async openBrowser(sessionId: string) {
if (this.browser) {
return this.browser
}
Expand All @@ -78,6 +78,18 @@ export class WebdriverBrowserProvider implements BrowserProvider {
...this.options,
logLevel: 'error',
capabilities: this.buildCapabilities(),
});

Check failure on line 81 in packages/browser/src/node/providers/webdriver.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

Extra semicolon

// closest we can do as for detecting browser crash
setImmediate(async () => {
while(true) {

Check failure on line 85 in packages/browser/src/node/providers/webdriver.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

Expected space(s) after "while"
try {
await this.browser?.getTitle()
} catch {

Check failure on line 88 in packages/browser/src/node/providers/webdriver.ts

View workflow job for this annotation

GitHub Actions / Lint: node-latest, ubuntu-latest

Closing curly brace appears on the same line as the subsequent block
const session = this.project.vitest._browserSessions.getSession(sessionId)
session?.reject(new Error('Page crashed when executing tests'))
}
}
})

return this.browser
Expand Down Expand Up @@ -120,8 +132,8 @@ export class WebdriverBrowserProvider implements BrowserProvider {
return capabilities
}

async openPage(_sessionId: string, url: string) {
const browserInstance = await this.openBrowser()
async openPage(sessionId: string, url: string) {
const browserInstance = await this.openBrowser(sessionId)
await browserInstance.url(url)
}

Expand Down

0 comments on commit 69299a2

Please sign in to comment.