Commit eca3e1c
fix: resolve 30-second connection hang in native fetch
Fixes connection hang issue similar to todoist-api-typescript#406 where
processes would hang for ~30 seconds after API calls complete when using
Node.js native fetch.
## Root Cause
Node.js native fetch uses undici with ~30s keepAlive timeout by default.
Additionally, the configured timeout (30s) was never actually applied to
fetch calls, and timeout handlers weren't being cleared properly.
## Changes
- **Add undici Agent**: Configure HTTP agent with 1ms keepAlive timeout
and pass via dispatcher option to prevent connection hangs
- **Fix timeout bug**: Actually apply the configured 30s timeout to fetch calls
- **Add timeout cleanup**: Implement proper clearTimeout functionality to
prevent hanging timeout handlers
- **Maintain compatibility**: CustomFetch implementations unaffected,
no breaking changes to public API
## Dependencies
- Added undici ^7.16.0 for connection management
## Testing
- All existing tests pass (166/166)
- Connection hang test confirms ~2s execution vs ~31s before fix
- Timeout enforcement now works correctly
Addresses same issues as:
- Doist/todoist-api-typescript#408
- Doist/todoist-api-typescript#414
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 3d43f25 commit eca3e1c
File tree
4 files changed
+134
-28
lines changed- src
4 files changed
+134
-28
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| |||
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
115 | 125 | | |
116 | 126 | | |
117 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
12 | 22 | | |
13 | 23 | | |
14 | 24 | | |
| |||
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
61 | 111 | | |
62 | 112 | | |
63 | 113 | | |
| |||
79 | 129 | | |
80 | 130 | | |
81 | 131 | | |
82 | | - | |
| 132 | + | |
83 | 133 | | |
84 | 134 | | |
85 | 135 | | |
86 | 136 | | |
87 | 137 | | |
88 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
89 | 142 | | |
90 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
91 | 152 | | |
92 | 153 | | |
93 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
94 | 162 | | |
95 | 163 | | |
96 | 164 | | |
| |||
113 | 181 | | |
114 | 182 | | |
115 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
116 | 189 | | |
117 | 190 | | |
118 | 191 | | |
| |||
126 | 199 | | |
127 | 200 | | |
128 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
129 | 207 | | |
130 | 208 | | |
131 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
132 | 215 | | |
133 | 216 | | |
134 | 217 | | |
| |||
156 | 239 | | |
157 | 240 | | |
158 | 241 | | |
159 | | - | |
| 242 | + | |
160 | 243 | | |
161 | 244 | | |
| 245 | + | |
162 | 246 | | |
163 | 247 | | |
164 | 248 | | |
| |||
0 commit comments