Skip to content

Commit cb23bd1

Browse files
Do not panic on nil io (#446)
1 parent 840879b commit cb23bd1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

client/transport/stdio.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ func (c *Stdio) Close() error {
200200
// cancel all in-flight request
201201
close(c.done)
202202

203-
if err := c.stdin.Close(); err != nil {
204-
return fmt.Errorf("failed to close stdin: %w", err)
203+
if c.stdin != nil {
204+
if err := c.stdin.Close(); err != nil {
205+
return fmt.Errorf("failed to close stdin: %w", err)
206+
}
205207
}
206-
if err := c.stderr.Close(); err != nil {
207-
return fmt.Errorf("failed to close stderr: %w", err)
208+
if c.stderr != nil {
209+
if err := c.stderr.Close(); err != nil {
210+
return fmt.Errorf("failed to close stderr: %w", err)
211+
}
208212
}
209213

210214
if c.cmd != nil {

0 commit comments

Comments
 (0)