This repository was archived by the owner on May 28, 2025. It is now read-only.
Fix response.body.getReader compatibility with node-fetch #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When using this library with
node-fetchinstead of nativefetch, it would fail with an error:response.body.getReader is not a function. This is becausenode-fetchdoesn't implement the Web Streams API in the same way as nativefetch.Solution
This PR adds support for both implementations:
response.body.getReader()is available (native fetch)getReader()The implementation maintains identical timeout and error handling behaviors between both approaches.
Changes
response.body.getReaderavailabilityprocessNodeStreamfunction for node-fetch compatible streamsThis change enables the library to work with both Node.js 18+ (with native fetch) and older Node.js versions using node-fetch as a fallback without any code changes required by the user.
Fixes #6.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.