matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

es6-promise is not a safe polyfill to recommend in your readme #111

Closed nilliams closed 3 years ago

nilliams commented 7 years ago

es6-promise's strict spec handling of uncaught exceptions (by not doing so at all) is a footgun. I don't feel like it should be the default recommendation of polyfill, and personally is the reason I've kept my team away from fetch() for months. Here are examples why:

Bluebird, however does the right thing:

I'm not saying Bluebird should be what you suggest instead, as I haven't dug into relative sizes/support/practicalities of that. I just feel that recommending people use es6-promise is going to cause a lot of people pain.

ysmood commented 7 years ago

I came from https://github.com/stefanpenner/es6-promise/issues/70#issuecomment-254969399

Maybe you could give Promise lib yaku a try.

Features

nilliams commented 7 years ago

Yaku looks excellent, and ticks all my personal boxes, thank you! I love the fact it's small and has passing test coverage too, seems like a good fit for alternative polyfill recommendation here!

I've been trying to pin this down even more, because when I actually hit it I felt it was way worse than I've actually demonstrated so far. And I remembered that even when you .catch() and re-throw, es6-promise does NOT surface the error/exception.

To me this is the most concrete example, where the developer is absolutely doing all the right things, and the error is STILL swallowed:

http://requirebin.com/?gist=9c59be0170fa7691a534705daf6b765d

And (now using Yaku as alternative), here's how you do it right:

http://requirebin.com/?gist=8e1d11f8754e58afd271a994760bb0c4

ysmood commented 7 years ago

If you have any problem with Yaku, please feel free to issue me. The project is quite active to user feedbacks now.

ysmood commented 7 years ago

Sad story. On Sat, 22 Oct 2016 at 4:15 AM Nick Williams notifications@github.com wrote:

To make matters even worse the author has now closed that issue thread, so it's not even visible to people now that it's an issue: stefanpenner/es6-promise#70 https://github.com/stefanpenner/es6-promise/issues/70

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matthew-andrews/isomorphic-fetch/issues/111#issuecomment-255454823, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWZQLp0R61aNwevzCqx_ZT5o5rHv0ACks5q2R1wgaJpZM4Kbj6l .

developit commented 7 years ago

I would recommend looking at promise-polyfill. I tested a bunch of polyfills and it's the smallest and I don't think it has that footgun.

matthew-andrews commented 3 years ago

This repo no longer recommends any polyfill.