@@ -22,58 +22,6 @@ function debug(...args: unknown[]) {
22
22
}
23
23
}
24
24
25
- async function tryCall < T > (
26
- fn : ( ) => Promise < T > ,
27
- ) : Promise < T | false | undefined > {
28
- try {
29
- return await fn ( )
30
- }
31
- catch ( err : any ) {
32
- const now = Date . now ( )
33
- // try for 30 seconds
34
- const canTry = ! reloadStart || now - Number ( reloadStart ) < 30_000
35
- const errorStack = ( ( ) => {
36
- if ( ! err ) {
37
- return null
38
- }
39
- return err . stack ?. includes ( err . message )
40
- ? err . stack
41
- : `${ err . message } \n${ err . stack } `
42
- } ) ( )
43
- debug (
44
- 'failed to resolve runner' ,
45
- 'trying again:' ,
46
- canTry ,
47
- 'time is' ,
48
- now ,
49
- 'reloadStart is' ,
50
- reloadStart ,
51
- ':\n' ,
52
- errorStack ,
53
- )
54
- if ( ! canTry ) {
55
- const error = serializeError (
56
- new Error ( 'Vitest failed to load its runner after 30 seconds.' ) ,
57
- )
58
- error . cause = serializeError ( err )
59
-
60
- await client . rpc . onUnhandledError ( error , 'Preload Error' )
61
- return false
62
- }
63
-
64
- if ( ! reloadStart ) {
65
- const newUrl = new URL ( location . href )
66
- newUrl . searchParams . set ( '__reloadStart' , now . toString ( ) )
67
- debug ( 'set the new url because reload start is not set to' , newUrl )
68
- location . href = newUrl . toString ( )
69
- }
70
- else {
71
- debug ( 'reload the iframe because reload start is set' , location . href )
72
- location . reload ( )
73
- }
74
- }
75
- }
76
-
77
25
async function prepareTestEnvironment ( files : string [ ] ) {
78
26
debug ( 'trying to resolve runner' , `${ reloadStart } ` )
79
27
const config = getConfig ( )
@@ -142,7 +90,7 @@ async function runTests(files: string[]) {
142
90
143
91
// if importing /@id / failed, we reload the page waiting until Vite prebundles it
144
92
try {
145
- preparedData = await tryCall ( ( ) => prepareTestEnvironment ( files ) )
93
+ preparedData = await prepareTestEnvironment ( files )
146
94
}
147
95
catch ( error ) {
148
96
debug ( 'data cannot be loaded because it threw an error' )
@@ -151,13 +99,6 @@ async function runTests(files: string[]) {
151
99
return
152
100
}
153
101
154
- // cannot load data, finish the test
155
- if ( preparedData === false ) {
156
- debug ( 'data cannot be loaded, finishing the test' )
157
- done ( files )
158
- return
159
- }
160
-
161
102
// page is reloading
162
103
if ( ! preparedData ) {
163
104
debug ( 'page is reloading, waiting for the next run' )
0 commit comments