Commit 12bcd17
authored
🤖 Fix SSH exec timeout to include connection establishment (#452)
Fixes a bug where SSH exec timeout was not comprehensive - it only
killed the SSH process after timeout but didn't configure SSH itself to
respect the timeout during connection establishment.
## Problem
When SSH connections were hanging during:
- DNS lookup
- TCP handshake
- SSH authentication
- Other connection establishment phases
...commands could take much longer than the specified timeout because
SSH has its own default timeout (often 75+ seconds) that wasn't being
configured.
## Solution
Added three SSH configuration options when a timeout is specified:
1. **`ConnectTimeout`** - Set to the configured timeout value to ensure
SSH respects the timeout during connection establishment
2. **`ServerAliveInterval=5`** - Send keepalive packets every 5 seconds
to detect dead connections
3. **`ServerAliveCountMax=2`** - Consider connection dead after 2 missed
keepalives (10 second detection window)
These options work together to ensure:
- Connection establishment can't hang indefinitely
- Established connections that die are detected quickly
- The overall timeout is respected from the moment the `ssh` command
starts
## Testing
- Added integration test that verifies timeout behavior (sleeps 10s with
1s timeout)
- Verifies command returns `EXIT_CODE_TIMEOUT` (-998) in ~1 second
- All changes pass typecheck and linting
_Generated with `cmux`_1 parent 368aed4 commit 12bcd17
2 files changed
+59
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | | - | |
104 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| |||
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
132 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
133 | 159 | | |
134 | 160 | | |
135 | 161 | | |
136 | | - | |
| 162 | + | |
137 | 163 | | |
138 | 164 | | |
139 | 165 | | |
| |||
175 | 201 | | |
176 | 202 | | |
177 | 203 | | |
178 | | - | |
| 204 | + | |
179 | 205 | | |
180 | 206 | | |
181 | 207 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
188 | 212 | | |
189 | 213 | | |
190 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
145 | 168 | | |
146 | 169 | | |
147 | 170 | | |
| |||
0 commit comments