@@ -47,6 +47,17 @@ function logSSHBackoffWait(initLogger: InitLogger, waitMs: number): void {
4747}
4848
4949// Re-export SSHRuntimeConfig from connection pool (defined there to avoid circular deps)
50+ const USER_INITIATED_SSH_MAX_WAIT_MS = 2 * 60 * 1000 ;
51+
52+ function userInitiatedSSHWaitExecOptions (
53+ initLogger : InitLogger
54+ ) : Pick < ExecOptions , "connectionMaxWaitMs" | "onConnectionWait" > {
55+ return {
56+ connectionMaxWaitMs : USER_INITIATED_SSH_MAX_WAIT_MS ,
57+ onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
58+ } ;
59+ }
60+
5061export type { SSHRuntimeConfig } from "./sshConnectionPool" ;
5162
5263/**
@@ -638,7 +649,7 @@ export class SSHRuntime implements Runtime {
638649
639650 // Step 2: Ensure the SSH host is reachable before doing expensive local work
640651 await sshConnectionPool . acquireConnection ( this . config , {
641- maxWaitMs : 2 * 60 * 1000 ,
652+ maxWaitMs : USER_INITIATED_SSH_MAX_WAIT_MS ,
642653 abortSignal,
643654 onWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
644655 } ) ;
@@ -707,8 +718,7 @@ export class SSHRuntime implements Runtime {
707718 cwd : "~" ,
708719 timeout : 300 , // 5 minutes for clone
709720 abortSignal,
710- connectionMaxWaitMs : 2 * 60 * 1000 ,
711- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
721+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
712722 } ) ;
713723
714724 const [ cloneStdout , cloneStderr , cloneExitCode ] = await Promise . all ( [
@@ -731,8 +741,7 @@ export class SSHRuntime implements Runtime {
731741 cwd : "~" ,
732742 timeout : 30 ,
733743 abortSignal,
734- connectionMaxWaitMs : 2 * 60 * 1000 ,
735- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
744+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
736745 }
737746 ) ;
738747 await createTrackingBranchesStream . exitCode ;
@@ -747,8 +756,7 @@ export class SSHRuntime implements Runtime {
747756 cwd : "~" ,
748757 timeout : 10 ,
749758 abortSignal,
750- connectionMaxWaitMs : 2 * 60 * 1000 ,
751- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
759+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
752760 }
753761 ) ;
754762
@@ -767,8 +775,7 @@ export class SSHRuntime implements Runtime {
767775 cwd : "~" ,
768776 timeout : 10 ,
769777 abortSignal,
770- connectionMaxWaitMs : 2 * 60 * 1000 ,
771- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
778+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
772779 }
773780 ) ;
774781 await removeOriginStream . exitCode ;
@@ -780,8 +787,7 @@ export class SSHRuntime implements Runtime {
780787 cwd : "~" ,
781788 timeout : 10 ,
782789 abortSignal,
783- connectionMaxWaitMs : 2 * 60 * 1000 ,
784- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
790+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
785791 } ) ;
786792
787793 const rmExitCode = await rmStream . exitCode ;
@@ -797,8 +803,7 @@ export class SSHRuntime implements Runtime {
797803 cwd : "~" ,
798804 timeout : 10 ,
799805 abortSignal,
800- connectionMaxWaitMs : 2 * 60 * 1000 ,
801- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
806+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
802807 } ) ;
803808 await rmStream . exitCode ;
804809 } catch {
@@ -837,8 +842,7 @@ export class SSHRuntime implements Runtime {
837842 timeout : 3600 , // 1 hour - generous timeout for init hooks
838843 abortSignal,
839844 env : muxEnv ,
840- connectionMaxWaitMs : 2 * 60 * 1000 ,
841- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
845+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
842846 } ) ;
843847
844848 // Create line-buffered loggers
@@ -912,8 +916,7 @@ export class SSHRuntime implements Runtime {
912916 cwd : "/tmp" ,
913917 timeout : 10 ,
914918 abortSignal,
915- connectionMaxWaitMs : 2 * 60 * 1000 ,
916- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
919+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
917920 } ) ;
918921 const mkdirExitCode = await mkdirStream . exitCode ;
919922 if ( mkdirExitCode !== 0 ) {
@@ -976,8 +979,7 @@ export class SSHRuntime implements Runtime {
976979 cwd : workspacePath , // Use the full workspace path for git operations
977980 timeout : 300 , // 5 minutes for git checkout (can be slow on large repos)
978981 abortSignal,
979- connectionMaxWaitMs : 2 * 60 * 1000 ,
980- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
982+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
981983 } ) ;
982984
983985 const [ stdout , stderr , exitCode ] = await Promise . all ( [
@@ -1042,8 +1044,7 @@ export class SSHRuntime implements Runtime {
10421044 cwd : workspacePath ,
10431045 timeout : 120 , // 2 minutes for network operation
10441046 abortSignal,
1045- connectionMaxWaitMs : 2 * 60 * 1000 ,
1046- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
1047+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
10471048 } ) ;
10481049
10491050 const fetchExitCode = await fetchStream . exitCode ;
@@ -1063,8 +1064,7 @@ export class SSHRuntime implements Runtime {
10631064 cwd : workspacePath ,
10641065 timeout : 60 , // 1 minute for fast-forward merge
10651066 abortSignal,
1066- connectionMaxWaitMs : 2 * 60 * 1000 ,
1067- onConnectionWait : ( waitMs ) => logSSHBackoffWait ( initLogger , waitMs ) ,
1067+ ...userInitiatedSSHWaitExecOptions ( initLogger ) ,
10681068 } ) ;
10691069
10701070 const [ mergeStderr , mergeExitCode ] = await Promise . all ( [
0 commit comments