Commit 25fb385
authored
🤖 fix: check abort signal in bash tool stream consumption (#541)
Fixes bash tool hanging when interrupted during execution by properly
handling abort signals in stream consumption.
## Problem
When a new message arrives while a bash command is executing, the tool
should abort quickly. However, after PR #537 removed the 10ms wait
workaround, the bash tool would hang if the abort signal fired while
`reader.read()` was blocked waiting for data. This was especially
noticeable over SSH or with commands producing continuous output.
The issue: `consumeStream()` didn't listen for abort events, so when the
process was killed but streams hadn't closed yet, `reader.read()` stayed
blocked indefinitely.
## Solution
Register an abort event listener that immediately cancels the reader
when abort fires:
```typescript
const abortHandler = () => reader.cancel().catch(() => {});
abortSignal?.addEventListener('abort', abortHandler);
```
This interrupts `reader.read()` mid-operation rather than checking abort
before each read (which has a race condition).
## Testing
- Added unit test verifying abort completes in < 2s with continuous
output
- All 44 bash unit tests pass
- All 8 executeBash integration tests pass
- All 963 unit tests pass
_Generated with `cmux`_1 parent 4a54146 commit 25fb385
2 files changed
+93
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1154 | 1214 | | |
1155 | 1215 | | |
1156 | 1216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
303 | 313 | | |
304 | 314 | | |
305 | 315 | | |
| |||
336 | 346 | | |
337 | 347 | | |
338 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
339 | 352 | | |
340 | 353 | | |
341 | 354 | | |
| |||
358 | 371 | | |
359 | 372 | | |
360 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
361 | 383 | | |
362 | 384 | | |
363 | 385 | | |
| |||
366 | 388 | | |
367 | 389 | | |
368 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
369 | 402 | | |
370 | 403 | | |
371 | 404 | | |
| |||
0 commit comments