react / react/react-native

Unhandled promises result in white screen of death (silent exceptions)

Aperta
#31,115 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Issue: Author Provided Repro
Lingua principale
C++
Stelle
127k
Fork
25.3k
Merge medio
1g 23h
PR unite (30g)
4

Descrizione

Description

Exceptions that occur within an unhandled promise do not trigger React exception handling. This makes it impossible to track exceptions or use standard exception handling methods. We call this the white screen of death.

React Native version:

System:
    OS: macOS 11.2.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 646.73 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v14.5.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
    Python: 3.8.6+ - /Users/alitamoore/.pyenv/shims/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^16.13.1 => 16.13.1 
    react-native: ^0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Build out an app with two buttons
  2. One button has the promised force crash, the other is not
  3. Press the promised force crash and you'll see a white screen
  4. Press the not promised force crash and you'll see the RED screen

Expected Results

Both buttons should show a RED screen or white screen should trigger exception handling

Snack, code example, screenshot, or link to a repository:

import { TouchableOpacity } from "react-native-gesture-handler";
import { Text, View } from "react-native-animatable";

export const forceCrash = () => {
    console.log("force crash");
    crash();
};

const forceCrashPromise = async () => forceCrash();
const forceCrashNotPromise = () => forceCrash();

const Button = () => (
    <View>
        <TouchableOpacity onPress={forceCrashPromise}>
            <Text>Force Crash Promise</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={forceCrashNotPromise}>
            <Text>Force Crash Not Promise</Text>
        </TouchableOpacity>
    </View>
);

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione TypeScript fornita e confronta gli handler dei pulsanti con Promise e senza Promise nell’app React Native. Riproduci il comportamento della schermata bianca e della schermata rossa; è completato quando un’eccezione proveniente dalla Promise non gestita raggiunge la stessa gestione visibile delle eccezioni del crash diretto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
react-native, typescript
Ambito
mobile
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.