react / react/react-native

AbortSignal, TypeError: AbortSignal.timeout is not a function

Open
#42,042 7 comments 16 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Author Provided Repro Needs: Author Feedback Resolution: PR Submitted
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

I want to abort a fetch request after 5 seconds. I am using following code:

const getStatus = () => {
  fetch(`${URL}/api/status`, {
    signal: AbortSignal.timeout(5000)
  }).then(response => {
    console.log(response)
  })
  .catch(err => {
    console.error(err.name, err.code, err.message, err.cause);
  })
};
Steps to reproduce
  1. Install React-Native
  2. Install newest node version
React Native Version

0.73.1

Affected Platforms

Runtime - Android

Output of npx react-native info
System:
    OS: Windows 10 10.0.19045
    CPU: (6) x64 Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
    Memory: 1.03 GB / 15.93 GB
  Binaries:
    Node: 21.5.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - ~\AppData\Roaming\npm\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowAllTrustedApps: Disabled
  IDEs:
    Android Studio: AI-212.5712.43.2112.8609683
    Visual Studio: Not Found
  Languages:
    Java: 17.0.8
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0
    react-native: 0.73.1 => 0.73.1
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
Stacktrace or Logs
TypeError: AbortSignal.timeout is not a function (it is undefined), js engine: hermes
Reproducer

https://github.com/HenrikZabel/abortsignal-bug/

Screenshots and Videos

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked abortsignal-bug reproducer and the reported React Native 0.73.1 Android runtime using Hermes. Trace the AbortSignal implementation or entry point that exposes timeout, then verify the reproducer no longer reports that AbortSignal.timeout is undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.