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.

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

See original GitHub issue

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>
);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
chrisgleincommented, Mar 17, 2021

@alita-moore No expertise I can lend here. Just trying to help triage incoming issues so they have the best chance of success.

1reaction
alita-moorecommented, Mar 9, 2021

@chrisglein crash is not defined on purpose, the app should crash when the button is pushed.

https://snack.expo.io/@alita-moore/repro31115

import * as React from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';

export const forceCrash = () => {
    crash();
};

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

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

export default function App() {
  return (
    <Button/>
  );
}

If you click Crash Not Promise that

If you click Crash Promise this

Notably, on the actual device the screen goes white but the point is despite the unhandled exception, the regular exception handling is not triggered

Read more comments on GitHub >

github_iconTop Results From Across the Web

React white screen of death, why does commenting out this ...
The blank white screen is caused by the error data. map is not a function , which is caused by your setting default...
Read more >
Tracking Unhandled Promise Rejections - TrackJS
If an error condition arises inside a promise, you “reject” the promise by calling the reject() function with an error. To handle a...
Read more >
WebGL video player issues - Unity Forum
"Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly ...
Read more >
[Solved]-"Unhandled Promise Rejection: NotAllowedError
Coding example for the question "Unhandled Promise Rejection: ... score:1. Accepted answer. This seems to be (again) a regression of an old WebKit...
Read more >
Update history for Microsoft Dynamics 365 Business Central
The Source No. is incorrectly stored in Detailed GST Ledger entries. ... Fix the check functionality for printed reports in the Custom Report...
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