Add an early invariant to debug a mystery crash (#18159)

This commit is contained in:
Dan Abramov
2020-02-28 11:56:36 +00:00
committed by GitHub
parent 7ea4e4111f
commit 4ee592e95a
10 changed files with 40 additions and 0 deletions
+13
View File
@@ -34,6 +34,7 @@ import {
enableUserTimingAPI,
enableScopeAPI,
enableBlocksAPI,
throwEarlyForMysteriousError,
} from 'shared/ReactFeatureFlags';
import {NoEffect, Placement} from 'shared/ReactSideEffectTags';
import {ConcurrentRoot, BlockingRoot} from 'shared/ReactRootTags';
@@ -453,6 +454,18 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
}
}
if (throwEarlyForMysteriousError) {
// Trying to debug a mysterious internal-only production failure.
// See D20130868 and t62461245.
// This is only on for RN FB builds.
if (current == null) {
throw Error('current is ' + current + " but it can't be");
}
if (workInProgress == null) {
throw Error('workInProgress is ' + workInProgress + " but it can't be");
}
}
workInProgress.childExpirationTime = current.childExpirationTime;
workInProgress.expirationTime = current.expirationTime;
+3
View File
@@ -105,6 +105,9 @@ export const deferPassiveEffectCleanupDuringUnmount = false;
// a deprecated pattern we want to get rid of in the future
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// --------------------------
// Future APIs to be deprecated
// --------------------------
@@ -50,6 +50,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = true;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
export const enableModernEventSystem = false;
export const warnAboutSpreadingKeyToJSX = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
@@ -99,6 +99,9 @@ export const warnUnstableRenderSubtreeIntoContainer = false;
export const enableModernEventSystem = false;
// Internal-only attempt to debug a React Native issue. See D20130868.
export const throwEarlyForMysteriousError = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars
type Check<_X, Y: _X, X: Y = _X> = null;