@@ -422,6 +422,32 @@ describe("CodexAppServerClient", () => {
422422 await expect ( harness . client . request ( "another/method" ) ) . rejects . toThrow ( "write EPIPE" ) ;
423423 } ) ;
424424
425+ it ( "handles stdout stream errors without crashing the process" , async ( ) => {
426+ const harness = createClientHarness ( ) ;
427+ clients . push ( harness . client ) ;
428+
429+ const pending = harness . client . request ( "test/method" ) ;
430+ const readError = Object . assign ( new Error ( "stdout pipe broke" ) , { code : "EIO" } ) ;
431+
432+ expect ( ( ) => harness . process . stdout . emit ( "error" , readError ) ) . not . toThrow ( ) ;
433+
434+ await expect ( pending ) . rejects . toThrow ( "stdout pipe broke" ) ;
435+ await expect ( harness . client . request ( "another/method" ) ) . rejects . toThrow ( "stdout pipe broke" ) ;
436+ } ) ;
437+
438+ it ( "handles stderr stream errors without crashing the process" , async ( ) => {
439+ const harness = createClientHarness ( ) ;
440+ clients . push ( harness . client ) ;
441+
442+ const pending = harness . client . request ( "test/method" ) ;
443+ const stderrError = Object . assign ( new Error ( "stderr pipe broke" ) , { code : "EIO" } ) ;
444+
445+ expect ( ( ) => harness . process . stderr . emit ( "error" , stderrError ) ) . not . toThrow ( ) ;
446+
447+ await expect ( pending ) . rejects . toThrow ( "stderr pipe broke" ) ;
448+ await expect ( harness . client . request ( "another/method" ) ) . rejects . toThrow ( "stderr pipe broke" ) ;
449+ } ) ;
450+
425451 it ( "preserves redacted app-server stderr on exit errors" , async ( ) => {
426452 const harness = createClientHarness ( ) ;
427453 clients . push ( harness . client ) ;
0 commit comments