File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,16 @@ func (tr *TestRunner) SendRequest(req Request) (*Response, error) {
8484 if err := tr .stdout .Err (); err != nil {
8585 return nil , fmt .Errorf ("failed to read response: %w" , err )
8686 }
87+ // Handler closed stdout prematurely.
88+ // Kill the process immediately to force stderr to close.
89+ // Without this, there's a rare scenario where stdout closes but stderr remains open,
90+ // causing io.ReadAll(tr.stderr) below to block indefinitely waiting for stderr EOF.
91+ if tr .cmd .Process != nil {
92+ tr .cmd .Process .Kill ()
93+ }
94+ if stderrOut , err := io .ReadAll (tr .stderr ); err == nil && len (stderrOut ) > 0 {
95+ return nil , fmt .Errorf ("handler closed unexpectedly: %s" , bytes .TrimSpace (stderrOut ))
96+ }
8797 return nil , fmt .Errorf ("handler closed unexpectedly" )
8898 }
8999 respLine := tr .stdout .Text ()
You can’t perform that action at this time.
0 commit comments