isomorphic-fetch
isomorphic-fetch copied to clipboard
Isomorphic fetch returns response with empty stream body
Hi team - After updating to NodeJs 18, we've started to see an issue where making an HTTP request using isomorphic-fetch to a url that returns streamed response returns a response with an empty stream even though the status returned is 200. Sharing the screenshots for the responses on NodeJS < 18 vs NodeJs >=18
Response returned on NodeJS < 18
Response returned on NodeJs >= 18
@y-chandra Hi, I have also encountered the same problem recently, did you find any fix for this ?
I am encountering differences in behavior between isomorphic-fetch and the fetch available in my native node version.
reponse.body.getReader is undefined when I use isomorphic-fetch. It's available when I the native fetch in node version 21
@pBread Were you able to find an alternative or work-around for this?
Currently using node 18 but turning off node's fetch with --no-experimental-fetch
I did notice that fetch is stable in node 21 - https://nodejs.org/docs/latest-v21.x/api/globals.html#fetch
@nsunga, I was trying to replace this hacky code w/isomorphic-fetch
. I ended up just leaving it in place. It seemed to work but it made writing tests a pain.
let isNode = false;
async function initializeFetch() {
if (typeof window === 'undefined' ||
typeof globalThis.fetch === 'undefined') {
const nodeFetch = await import('node-fetch');
fetch = nodeFetch.default;
isNode = true;
} else {
fetch = globalThis.fetch;
}
}