File tree Expand file tree Collapse file tree 2 files changed +42
-24
lines changed
Expand file tree Collapse file tree 2 files changed +42
-24
lines changed Original file line number Diff line number Diff line change @@ -64,19 +64,28 @@ export async function hibernateSandbox(id?: string) {
6464 let failCount = 0 ;
6565 const results : CommandResult [ ] = [ ] ;
6666
67- for ( const sandboxId of ids ) {
68- try {
69- const result = await hibernateSingleSandbox ( sandboxId , null as any ) ;
70- results . push ( result ) ;
71- if ( result . success ) {
72- successCount ++ ;
73- } else {
67+ // Run all hibernations in parallel
68+ const hibernatePromises = ids . map ( ( sandboxId ) =>
69+ hibernateSingleSandbox ( sandboxId , null as any )
70+ . then ( ( result ) => {
71+ results . push ( result ) ;
72+ if ( result . success ) {
73+ successCount ++ ;
74+ } else {
75+ failCount ++ ;
76+ }
77+ return result ;
78+ } )
79+ . catch ( ( ) => {
7480 failCount ++ ;
75- }
76- } catch ( error ) {
77- failCount ++ ;
78- }
79- }
81+ return {
82+ success : false ,
83+ message : `Failed to hibernate sandbox ${ sandboxId } ` ,
84+ } ;
85+ } )
86+ ) ;
87+
88+ await Promise . all ( hibernatePromises ) ;
8089
8190 // Final summary
8291 if ( failCount === 0 ) {
Original file line number Diff line number Diff line change @@ -64,19 +64,28 @@ export async function shutdownSandbox(id?: string) {
6464 let failCount = 0 ;
6565 const results : CommandResult [ ] = [ ] ;
6666
67- for ( const sandboxId of ids ) {
68- try {
69- const result = await shutdownSingleSandbox ( sandboxId , null as any ) ;
70- results . push ( result ) ;
71- if ( result . success ) {
72- successCount ++ ;
73- } else {
67+ // Run all shutdowns in parallel
68+ const shutdownPromises = ids . map ( ( sandboxId ) =>
69+ shutdownSingleSandbox ( sandboxId , null as any )
70+ . then ( ( result ) => {
71+ results . push ( result ) ;
72+ if ( result . success ) {
73+ successCount ++ ;
74+ } else {
75+ failCount ++ ;
76+ }
77+ return result ;
78+ } )
79+ . catch ( ( ) => {
7480 failCount ++ ;
75- }
76- } catch ( error ) {
77- failCount ++ ;
78- }
79- }
81+ return {
82+ success : false ,
83+ message : `Failed to shutdown sandbox ${ sandboxId } ` ,
84+ } ;
85+ } )
86+ ) ;
87+
88+ await Promise . all ( shutdownPromises ) ;
8089
8190 // Final summary
8291 if ( failCount === 0 ) {
You can’t perform that action at this time.
0 commit comments