@@ -66,21 +66,33 @@ async function waitForAck( worker, { fullBrowser, verbose } ) {
66
66
} ) ;
67
67
}
68
68
69
- async function ensureAcknowledged ( worker , restarts ) {
69
+ async function restartWorker ( worker ) {
70
+ await cleanupWorker ( worker , worker . options ) ;
71
+ await createBrowserWorker (
72
+ worker . url ,
73
+ worker . browser ,
74
+ worker . options ,
75
+ worker . restarts + 1
76
+ ) ;
77
+ }
78
+
79
+ export async function restartBrowser ( browser ) {
80
+ const fullBrowser = getBrowserString ( browser ) ;
81
+ const worker = workers [ fullBrowser ] ;
82
+ if ( worker ) {
83
+ await restartWorker ( worker ) ;
84
+ }
85
+ }
86
+
87
+ async function ensureAcknowledged ( worker ) {
70
88
const fullBrowser = getBrowserString ( worker . browser ) ;
71
89
const verbose = worker . options . verbose ;
72
90
try {
73
91
await waitForAck ( worker , { fullBrowser, verbose } ) ;
74
92
return worker ;
75
93
} catch ( error ) {
76
94
console . error ( error . message ) ;
77
- await cleanupWorker ( worker , { verbose } ) ;
78
- await createBrowserWorker (
79
- worker . url ,
80
- worker . browser ,
81
- worker . options ,
82
- restarts + 1
83
- ) ;
95
+ await restartWorker ( worker . browser ) ;
84
96
}
85
97
}
86
98
@@ -132,7 +144,7 @@ export async function createBrowserWorker( url, browser, options, restarts = 0 )
132
144
133
145
// Wait for the worker to show up in the list
134
146
// before returning it.
135
- return ensureAcknowledged ( worker , restarts ) ;
147
+ return ensureAcknowledged ( worker ) ;
136
148
}
137
149
138
150
export async function setBrowserWorkerUrl ( browser , url ) {
@@ -159,13 +171,7 @@ export async function checkLastTouches() {
159
171
} min.`
160
172
) ;
161
173
}
162
- await cleanupWorker ( worker , options ) ;
163
- await createBrowserWorker (
164
- worker . url ,
165
- worker . browser ,
166
- options ,
167
- worker . restarts
168
- ) ;
174
+ await restartWorker ( worker ) ;
169
175
}
170
176
}
171
177
}
0 commit comments