JakeChampion / fetch

A window.fetch JavaScript polyfill.
MIT License
25.76k stars 2.84k forks source link

fix: catch and reject with error if new Response throws inside resolve #1471

Open pablomikel opened 1 month ago

pablomikel commented 1 month ago

If Response() throws when fetch() is trying to resolve it'll throw an error that can't be handled.

This change would catch the error when trying to resolve and instead reject the fetch promise with the error so it can be handled by a catch higher up.

I ran into this issue in a react-native project when a server unpredictably returned a 600 status code, ultimately causing react-native to panic/crash and I was unable to handle the thrown RangeError in any way.