@@ -320,13 +320,13 @@ export class SSHRuntime implements Runtime {
320320 /**
321321 * Get file statistics over SSH
322322 */
323- async stat ( path : string , _abortSignal ?: AbortSignal ) : Promise < FileStat > {
323+ async stat ( path : string , abortSignal ?: AbortSignal ) : Promise < FileStat > {
324324 // Use stat with format string to get: size, mtime, type
325325 // %s = size, %Y = mtime (seconds since epoch), %F = file type
326- // Note: timeout is <10s so no abort signal needed per requirement
327326 const stream = await this . exec ( `stat -c '%s %Y %F' ${ shescape . quote ( path ) } ` , {
328327 cwd : this . config . srcBaseDir ,
329- timeout : 10 , // 10 seconds - stat should be fast (no abort needed per requirement)
328+ timeout : 10 , // 10 seconds - stat should be fast
329+ abortSignal,
330330 } ) ;
331331
332332 const [ stdout , stderr , exitCode ] = await Promise . all ( [
@@ -547,6 +547,13 @@ export class SSHRuntime implements Runtime {
547547 log . debug ( `Creating bundle: ${ command } ` ) ;
548548 const proc = spawn ( "bash" , [ "-c" , command ] ) ;
549549
550+ // Handle abort signal
551+ const abortHandler = ( ) => {
552+ proc . kill ( ) ;
553+ reject ( new Error ( "Bundle creation aborted" ) ) ;
554+ } ;
555+ abortSignal ?. addEventListener ( "abort" , abortHandler ) ;
556+
550557 streamProcessToLogger ( proc , initLogger , {
551558 logStdout : false ,
552559 logStderr : true ,
@@ -558,14 +565,18 @@ export class SSHRuntime implements Runtime {
558565 } ) ;
559566
560567 proc . on ( "close" , ( code ) => {
561- if ( code === 0 ) {
568+ abortSignal ?. removeEventListener ( "abort" , abortHandler ) ;
569+ if ( abortSignal ?. aborted ) {
570+ reject ( new Error ( "Bundle creation aborted" ) ) ;
571+ } else if ( code === 0 ) {
562572 resolve ( ) ;
563573 } else {
564574 reject ( new Error ( `Failed to create bundle: ${ stderr } ` ) ) ;
565575 }
566576 } ) ;
567577
568578 proc . on ( "error" , ( err ) => {
579+ abortSignal ?. removeEventListener ( "abort" , abortHandler ) ;
569580 reject ( err ) ;
570581 } ) ;
571582 } ) ;
@@ -616,6 +627,7 @@ export class SSHRuntime implements Runtime {
616627 {
617628 cwd : "~" ,
618629 timeout : 10 ,
630+ abortSignal,
619631 }
620632 ) ;
621633
@@ -633,6 +645,7 @@ export class SSHRuntime implements Runtime {
633645 {
634646 cwd : "~" ,
635647 timeout : 10 ,
648+ abortSignal,
636649 }
637650 ) ;
638651 await removeOriginStream . exitCode ;
@@ -643,6 +656,7 @@ export class SSHRuntime implements Runtime {
643656 const rmStream = await this . exec ( `rm ${ bundleTempPath } ` , {
644657 cwd : "~" ,
645658 timeout : 10 ,
659+ abortSignal,
646660 } ) ;
647661
648662 const rmExitCode = await rmStream . exitCode ;
@@ -657,6 +671,7 @@ export class SSHRuntime implements Runtime {
657671 const rmStream = await this . exec ( `rm -f ${ bundleTempPath } ` , {
658672 cwd : "~" ,
659673 timeout : 10 ,
674+ abortSignal,
660675 } ) ;
661676 await rmStream . exitCode ;
662677 } catch {
@@ -747,7 +762,7 @@ export class SSHRuntime implements Runtime {
747762
748763 async createWorkspace ( params : WorkspaceCreationParams ) : Promise < WorkspaceCreationResult > {
749764 try {
750- const { projectPath, branchName, initLogger } = params ;
765+ const { projectPath, branchName, initLogger, abortSignal } = params ;
751766 // Compute workspace path using canonical method
752767 const workspacePath = this . getWorkspacePath ( projectPath , branchName ) ;
753768
@@ -768,6 +783,7 @@ export class SSHRuntime implements Runtime {
768783 const mkdirStream = await this . exec ( parentDirCommand , {
769784 cwd : "/tmp" ,
770785 timeout : 10 ,
786+ abortSignal,
771787 } ) ;
772788 const mkdirExitCode = await mkdirStream . exitCode ;
773789 if ( mkdirExitCode !== 0 ) {
@@ -966,6 +982,7 @@ export class SSHRuntime implements Runtime {
966982 const checkStream = await this . exec ( checkScript , {
967983 cwd : this . config . srcBaseDir ,
968984 timeout : 10 ,
985+ abortSignal,
969986 } ) ;
970987
971988 await checkStream . stdin . close ( ) ;
0 commit comments