Closed Spiralis closed 3 years ago
Hi @Spiralis! Thanks for opening an issue. I couldn't reproduce the error. I've forked your code to test it: https://codesandbox.io/s/abortable-fetch-forked-89tvi?file=/src/index.js
Yeah. I just got it working myself. I am not able to see the problem in any way. I must have missed out on something essential, yet I am not seeing it.
But, happy to see it working :)
@lquixada, I think I found the reason. I believe my failing cross-fetch was v2.2.3. Since cross-fetch failed for me with the AbortController feature, I tried other alternatives - which had their own set of problems... So I reinstalled cross-fetch to give it another go - and potentially instead contribute in regards to help fixing it. With that reinstall I got v3.0.4 - which works.
I was so sure that I was on the latest cross-fetch at the time I had the problems. I was fooled after runniing a yarn upgrade-interactive
, which did not prompt me to do the major v3 upgrade. Lesson learned, again... :|
But, thanks for the prompt reply. And thanks for the project. Great work :)
@Spiralis I'm glad it worked out for you. 👍 Ps: the latest version is 3.0.6.
I am using the
AbortController
feature (sample) in my code, and for my jest tests which usesjest-fetch-mock
, theAbortController.abort()
method works.In my browser I can see that a manual test of the
window.fetch
works fine with theAbortController
too. But, whencross-fetch
is handling the fetch in the browser the abortcontroller signal is ignored - it seems.I also see that there is no code in the cross-fetch project that deals with the abort-controller, and no issues mentioning it. I can see that the code supports setting the
RequestInit.signal
property though. So, I was expecting it to be passed into thewindow.fetch()
, which I assume that cross-fetch is perhaps using under the hood - when run in the browser?