You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We came across a bug in our code where we expected await fetch('https://example.com/a-large-file.zip', { method: 'HEAD' }) to just get the HTTP status code and not fetch the HTTP body data, however we hit a memory issue because all the data was downloaded and stored in RAM.
I believe I have observed two deviations from the way native fetch works in whatwg-fetch v3.6.20:
await fetch(...) does not resolve until the entire body has been downloaded.
It should be possible to check the status code before the download of the HTTP request body is complete. e.g
constresponse=awaitfetch('https://example.com/a-large-file.zip')if(response.status===200){// I should be able to do something here before the file download has completedconsole.log('File exists! Downloading...')constdata=awaitresponse.body()}
await fetch(..., { method: 'HEAD' }) exhibits the same behaviour as above but it should not fetch the HTTP body at all. e.g.
constresponse=awaitfetch('https://example.com/a-large-file.zip',{method: 'HEAD'})if(response.status===200){// I should be able to do something here immediately// In practice we only reach here after the file has finished downloadingconsole.log('File exists!')}
We've now upgraded to Node 18 to switch to the native fetch method which does not exhibit the above behaviour.
The text was updated successfully, but these errors were encountered:
We came across a bug in our code where we expected
await fetch('https://example.com/a-large-file.zip', { method: 'HEAD' })
to just get the HTTP status code and not fetch the HTTP body data, however we hit a memory issue because all the data was downloaded and stored in RAM.I believe I have observed two deviations from the way native
fetch
works inwhatwg-fetch
v3.6.20:await fetch(...)
does not resolve until the entire body has been downloaded.It should be possible to check the status code before the download of the HTTP request body is complete. e.g
await fetch(..., { method: 'HEAD' })
exhibits the same behaviour as above but it should not fetch the HTTP body at all. e.g.We've now upgraded to Node 18 to switch to the native
fetch
method which does not exhibit the above behaviour.The text was updated successfully, but these errors were encountered: