Repository navigation
Commit 976972b
fix: handle null body status in createCustomFetch proxy
When an MCP server returns HTTP 204 No Content (e.g., on DELETE session
termination), the proxy's createCustomFetch crashes with:
TypeError: Response constructor: Invalid response status code 204
This happens because node-fetch returns a non-null body stream even for
204 responses, and the Web Response constructor rejects a body for null
body statuses per the Fetch spec.
Additionally, returning the raw node-fetch response (path modelcontextprotocol#3) causes
`response.body?.cancel is not a function` because node-fetch uses
Node.js Readable streams, not Web ReadableStreams.
Fix: detect null body statuses (101, 204, 205, 304) and return a proper
Web Response with null body before the SSE stream conversion check.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>1 parent dd53302 commit 976972b
1 file changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
341 | 364 | | |
342 | 365 | | |
343 | 366 | | |
| |||
0 commit comments