Commit 8fece22
fix(version-self-check): clear timer in finally + unref to avoid event-loop pin
Codex review feedback on PR #21. The previous implementation only
cleared the abort timer on the success path — when `fetchImpl`
rejected (network error, malformed body), the catch block returned
null but the timer was left running until it fired. In a long-lived
MCP server that's invisible (the timer just expires harmlessly
seconds later), but in short-lived processes / tests it would
prevent the event loop from exiting cleanly.
Two-line fix:
- `timer.unref()` (Node-only, optional-chained for portability) so
the timer alone never keeps the loop alive.
- `clearTimeout(timer)` moved into a `finally` block so it runs on
both success and exception paths.
Belt-and-braces by design: either fix alone is sufficient, but
together they leave no path for a stray timer.
19 version-self-check tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fabe48e commit 8fece22
1 file changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | | - | |
54 | | - | |
55 | 61 | | |
56 | | - | |
57 | 62 | | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
| |||
0 commit comments