File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,11 @@ func (s *StdioServer) processMessage(
244244 line string ,
245245 writer io.Writer ,
246246) error {
247+ // If line is empty, likely due to ctx cancellation
248+ if len (line ) == 0 {
249+ return nil
250+ }
251+
247252 // Parse the message as raw JSON
248253 var rawMessage json.RawMessage
249254 if err := json .Unmarshal ([]byte (line ), & rawMessage ); err != nil {
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ func TestStdioServer(t *testing.T) {
5050 if err != nil && err != io .EOF && err != context .Canceled {
5151 serverErrCh <- err
5252 }
53+ stdoutWriter .Close ()
5354 close (serverErrCh )
5455 }()
5556
@@ -106,7 +107,6 @@ func TestStdioServer(t *testing.T) {
106107 // Clean up
107108 cancel ()
108109 stdinWriter .Close ()
109- stdoutWriter .Close ()
110110
111111 // Check for server errors
112112 if err := <- serverErrCh ; err != nil {
@@ -162,6 +162,7 @@ func TestStdioServer(t *testing.T) {
162162 if err != nil && err != io .EOF && err != context .Canceled {
163163 serverErrCh <- err
164164 }
165+ stdoutWriter .Close ()
165166 close (serverErrCh )
166167 }()
167168
@@ -260,7 +261,6 @@ func TestStdioServer(t *testing.T) {
260261 // Clean up
261262 cancel ()
262263 stdinWriter .Close ()
263- stdoutWriter .Close ()
264264
265265 // Check for server errors
266266 if err := <- serverErrCh ; err != nil {
You can’t perform that action at this time.
0 commit comments