Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Showing 1 changed file with 8 additions and 2 deletions.
| @@ -13,8 +13,8 @@ import ( | ||
| 13 | 13 | "syscall" |
| 14 | 14 | "time" |
| 15 | 15 | |
| 16 | - "codey/internal/config" | |
| 17 | - "codey/internal/tools" | |
| 16 | + "github.com/johannSo/codey/internal/config" | |
| 17 | + "github.com/johannSo/codey/internal/tools" | |
| 18 | 18 | ) |
| 19 | 19 | |
| 20 | 20 | // clientVersion is what initialize reports as clientInfo.version. It is |
| @@ -173,6 +173,12 @@ func start(ctx context.Context, dir, name string, spec config.MCPServer) (*clien | ||
| 173 | 173 | defer cancel() |
| 174 | 174 | infos, err := handshake(ctx, c) |
| 175 | 175 | if err != nil { |
| 176 | + // Stderr is copied in by exec on a goroutine that only Wait is sure | |
| 177 | + // to have seen finish: the stdout EOF that failed the handshake can | |
| 178 | + // arrive first, and read now the tail would be missing the very line | |
| 179 | + // that explains the exit. Close kills and reaps the process; the | |
| 180 | + // caller's later Close is a no-op. | |
| 181 | + _ = c.Close() | |
| 176 | 182 | if s := strings.TrimSpace(stderr.String()); s != "" { |
| 177 | 183 | err = fmt.Errorf("%w\nserver stderr:\n%s", err, s) |
| 178 | 184 | } |