()
| 206 | let currentProc = proc |
| 207 | |
| 208 | const reconnect = async (): Promise<Subprocess> => { |
| 209 | logForDebugging('[SSH] reconnect: re-spawning SSH process with --continue') |
| 210 | const reconnectArgs = [...sshArgs] |
| 211 | const cmdIdx = reconnectArgs.length - 1 |
| 212 | const existingCmd = reconnectArgs[cmdIdx]! |
| 213 | if (!existingCmd.includes('--continue')) { |
| 214 | reconnectArgs[cmdIdx] = existingCmd.replace( |
| 215 | / -p(?:\s|$)/, |
| 216 | ' -p --continue ', |
| 217 | ) |
| 218 | } |
| 219 | |
| 220 | const newProc = Bun.spawn(reconnectArgs, { |
| 221 | stdin: 'pipe', |
| 222 | stdout: 'pipe', |
| 223 | stderr: 'pipe', |
| 224 | }) |
| 225 | |
| 226 | const newStderrChunks: string[] = [] |
| 227 | collectStderr(newProc, newStderrChunks) |
| 228 | |
| 229 | await waitForInit(newProc, remoteCwd) |
| 230 | currentProc = newProc |
| 231 | stderrChunks.length = 0 |
| 232 | stderrChunks.push(...newStderrChunks) |
| 233 | |
| 234 | return newProc |
| 235 | } |
| 236 | |
| 237 | return { |
| 238 | remoteCwd, |
no test coverage detected