Commit e5828e2
fix: resolve request hang with large API responses (#437)
* fix: resolve request hang with `pageSize` and `fetchLinks`
Replace `response.clone()` with a memoized response wrapper that caches
promises for `text()`, `json()`, and `blob()` reads. This allows multiple
callers sharing a deduplicated request to safely read from the same response
without stream/body handling issues.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: prevent body read conflicts in memoized responses
Clone the response before reading text/blob to avoid "body already read"
errors when both methods are called on the same memoized response.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: buffer response body immediately to avoid backpressure
Buffers the response body as a blob immediately instead of using
response.clone(). This fixes hanging requests in Node.js 22+ where
backpressure blocks the cloned stream when the original is not consumed.
See: node-fetch/node-fetch#139
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix: simplify memoizeResponse to reduce complexity
Replace verbose wrapper with lazy caching variables with a compact
implementation that eagerly buffers the blob and derives text/json
from it on each call.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: return fresh Response per mock call to match real fetch
mockResolvedValue reuses one Response object across calls, but real
fetch always returns a fresh Response. Use mockImplementation so each
call creates a new Response, avoiding "Body has already been read".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: clarify memoizeResponse comment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 826b079 commit e5828e2
File tree
3 files changed
+31
-9
lines changed- src/lib
- test
3 files changed
+31
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
107 | 127 | | |
108 | 128 | | |
109 | 129 | | |
| |||
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
146 | 168 | | |
147 | 169 | | |
148 | 170 | | |
| |||
162 | 184 | | |
163 | 185 | | |
164 | 186 | | |
165 | | - | |
| 187 | + | |
166 | 188 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| |||
0 commit comments