matthew-andrews / isomorphic-fetch

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

AbortController not working with this library #185

Closed quorth0n closed 4 years ago

quorth0n commented 4 years ago

The following code results in the fetch executing as normal with no termination.

  require('isomorphic-fetch');

  const controller = new AbortController();

  setTimeout(() => {
    controller.abort();
  }, 2000);

  return fetch(url, { signal: controller.signal })
    .then(response => {
      return response;
    })
    .catch(error => {
      throw new Error(error.message);
    });

Using node-fetch instead of this library allowed me to fix this issue with no other implementation changes.

eeeman1 commented 4 years ago

what solutions were found?

quorth0n commented 4 years ago

@eeeman1 using node-fetch :)

atuttle commented 4 years ago

I created @atuttle/smart-fetch which adds AbortController into the mix, among other things.

matthew-andrews commented 4 years ago

I believe this will be coming in the next version of this package.