File tree 1 file changed +7
-7
lines changed
components/server/src/workspace
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -337,14 +337,14 @@ export class WorkspaceStarter {
337
337
338
338
// check if there has been an instance before, i.e. if this is a restart
339
339
const pastInstances = await this . workspaceDb . trace ( { span } ) . findInstances ( workspace . id ) ;
340
- const hasValidBackup = pastInstances . some (
341
- ( i ) => ! ! i . status && ! ! i . status . conditions && ! i . status . conditions . failed ,
342
- ) ;
343
340
let lastValidWorkspaceInstance : WorkspaceInstance | undefined ;
344
- if ( hasValidBackup ) {
345
- lastValidWorkspaceInstance = pastInstances . reduce ( ( previousValue , currentValue ) =>
346
- currentValue . creationTime > previousValue . creationTime ? currentValue : previousValue ,
347
- ) ;
341
+ // Sorted from latest to oldest
342
+ for ( const i of pastInstances . sort ( ( a , b ) => ( a . creationTime > b . creationTime ? - 1 : 1 ) ) ) {
343
+ // We're trying to figure out whether there was a successful backup or not, and if yes for which instance
344
+ if ( ! ! i . status . conditions && ! i . status . conditions . failed ) {
345
+ lastValidWorkspaceInstance = i ;
346
+ break ;
347
+ }
348
348
}
349
349
350
350
const ideConfig = await this . ideService . getIDEConfig ( ) ;
You can’t perform that action at this time.
0 commit comments