@@ -88,6 +88,34 @@ describe("OpenSSHTransport.spawnRemoteProcess", () => {
8888 expect ( markHealthy ) . not . toHaveBeenCalled ( ) ;
8989 } ) ;
9090
91+ test ( "truncates connection-failure stderr before reporting shard health" , async ( ) => {
92+ const release = mock ( ( ) => undefined ) ;
93+ let reportedError : string | undefined ;
94+ const reportFailure = mock ( ( error : string ) => {
95+ reportedError = error ;
96+ } ) ;
97+ const markHealthy = mock ( ( ) => undefined ) ;
98+ acquireLeaseSpy . mockResolvedValue ( {
99+ controlPath : "/tmp/mux-ssh-test-shard" ,
100+ shardId : "shard-0" ,
101+ release,
102+ reportFailure,
103+ markHealthy,
104+ } ) ;
105+ const transport = new OpenSSHTransport ( { host : "remote.example.com" } ) ;
106+ const spawnResult = await transport . spawnRemoteProcess ( "echo ok" , { } ) ;
107+ const longStderr = `${ "x" . repeat ( 1100 ) } \n` ;
108+
109+ spawnResult . onExit ?.( 255 , longStderr ) ;
110+
111+ if ( reportedError == null ) {
112+ throw new Error ( "Expected reportFailure to be called with a string error summary" ) ;
113+ }
114+ expect ( reportedError . length ) . toBeLessThan ( longStderr . trim ( ) . length ) ;
115+ expect ( reportedError . endsWith ( "…" ) ) . toBe ( true ) ;
116+ expect ( markHealthy ) . not . toHaveBeenCalled ( ) ;
117+ } ) ;
118+
91119 test ( "explicit headless (no service) includes host-key fallback options and BatchMode=yes" , async ( ) => {
92120 setSshPromptCapability ( false ) ;
93121 setOpenSSHHostKeyPolicyMode ( "headless-fallback" ) ;
0 commit comments