Skip to content

Commit 5a45a7c

Browse files
authoredFeb 13, 2025··
fix(browser): cleanup timeout on resolve and give more information in the error (#7487)
1 parent accd2ed commit 5a45a7c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎packages/vitest/src/node/browser/sessions.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { TestProject } from '../project'
22
import type { BrowserServerStateSession } from '../types/browser'
33
import { createDefer } from '@vitest/utils'
4+
import { relative } from 'pathe'
45

56
export class BrowserSessions {
67
private sessions = new Map<string, BrowserServerStateSession>()
@@ -13,7 +14,8 @@ export class BrowserSessions {
1314
const defer = createDefer<void>()
1415

1516
const timeout = setTimeout(() => {
16-
defer.reject(new Error(`Failed to connect to the browser session "${sessionId}" within the timeout.`))
17+
const tests = files.map(file => relative(project.config.root, file)).join('", "')
18+
defer.reject(new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] for "${tests}" within the timeout.`))
1719
}, project.vitest.config.browser.connectTimeout ?? 60_000).unref()
1820

1921
this.sessions.set(sessionId, {
@@ -25,6 +27,7 @@ export class BrowserSessions {
2527
},
2628
resolve: () => {
2729
defer.resolve()
30+
clearTimeout(timeout)
2831
this.sessions.delete(sessionId)
2932
},
3033
reject: defer.reject,

0 commit comments

Comments
 (0)
Please sign in to comment.