question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AbortController is missing

See original GitHub issue

Is this a bug report?

Yes. AbortController is a new spec (you can find info here: https://developers.google.com/web/updates/2017/09/abortable-fetch)

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
  OS: Linux 4.13
  Node: 8.9.4
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Not Found

Packages: (wanted => installed)
  react: ^16.0.0 => 16.2.0
  react-native: ^0.53.0 => 0.53.0

Steps to Reproduce

  1. Istantiate an AbortController
  2. Write a fetch request passing the signal
  3. Try to abort the fetch request

Expected Behavior

The requested behaviour is to abort the fetch request.

Actual Behavior

Nothing happens

Reproducible Demo

Something like this:

const controller = new AbortController();
const signal = controller.signal;

setTimeout(() => controller.abort(), 5000);

fetch(url, { signal }).then(response => {
  return response.text();
}).then(text => {
  console.log(text);
});

My question is a technical one: is the react native core that needs to be updated in order to support this? Or is it something that babel can patch with a new version?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:17
  • Comments:31 (7 by maintainers)

github_iconTop GitHub Comments

15reactions
giacomocerquonecommented, Feb 27, 2018

Great, it works! I’m not on a create react app, but I’ve just followed the instruction for it (I’m actually on a react-native project not even on a create react native app

So installed the module, imported it like this:

import 'abortcontroller-polyfill';

and then used it like this:

const AbortController = window.AbortController;
const controller = new AbortController()
const signal = controller.signal

I’d not close the issue, because we’re still waiting for the official spec. Thank you @chirag04 for linking me the right resource ☺️

10reactions
JordanRichards-hxcommented, Jul 4, 2019

Support for this was included in the new version; 0.60, which was released yesterday.

https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#060

Read more comments on GitHub >

github_iconTop Results From Across the Web

AbortController missing in TypeScript - fetch api - Stack Overflow
It's because you are missing the value DOM in the lib array of your tsconfig.json. If you check the official repo, you will...
Read more >
The complete guide to AbortController in Node.js
The AbortController API in Node.js is a wonderful new development - learn all about it in this comprehensive tutorial.
Read more >
node-abort-controller - npm
AbortController for Node based on EventEmitter. Latest version: 3.0.1, last published: a year ago. Start using node-abort-controller in your ...
Read more >
How to Cancel Promise with AbortController - LeanyLabs
Many APIs require an abort mechanism that's missing from the language. Before the standard, every library had to roll their custom solutions to...
Read more >
abort-controller - npm Package Health Analysis - Snyk
Learn more about abort-controller: package health score, popularity, security, maintenance, ... Looks like abort-controller is missing a security policy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found