Commit 556ac52
committed
fix(document): improve cancellation responsiveness in polling loop (Issue #10)
Added defensive abort check after sleep() completes for faster cancellation response.
Changes:
- Added explicit abortSignal check after sleep() in pollDocumentStatus()
- Exits immediately if cancelled during sleep instead of waiting for next iteration
- Avoids unnecessary poll interval calculation when operation is cancelled
Technical Details:
- sleep() method already has isSettled flag preventing double settlement (correct)
- This change adds post-await check for immediate cancellation detection
- Catches edge case where abort happens just as sleep timeout completes
- Defensive programming pattern improves responsiveness to Ctrl+C
Impact:
- More responsive cancellation behavior
- Exits faster when user cancels document translation
- No functional changes - all 1454 tests pass
Location: src/services/document-translation.ts:182-1861 parent 6f40518 commit 556ac52
2 files changed
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
| |||
0 commit comments