@samitouri / QOS-React / commits / 4ee592e95a

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

Dan Abramov committed Feb 28, 2020 at 11:56 UTC 4ee592e95a5f78daed575a047d47f74f046940f3
10 files changed +40
packages/react-reconciler/src/ReactFiber.js
+13
@@ -34,6 +34,7 @@ import {
34 enableUserTimingAPI,
35 enableScopeAPI,
36 enableBlocksAPI,
37 + throwEarlyForMysteriousError,
38 } from 'shared/ReactFeatureFlags';
39 import {NoEffect, Placement} from 'shared/ReactSideEffectTags';
40 import {ConcurrentRoot, BlockingRoot} from 'shared/ReactRootTags';
@@ -453,6 +454,18 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
454 }
455 }
456
457 + if (throwEarlyForMysteriousError) {
458 + // Trying to debug a mysterious internal-only production failure.
459 + // See D20130868 and t62461245.
460 + // This is only on for RN FB builds.
461 + if (current == null) {
462 + throw Error('current is ' + current + " but it can't be");
463 + }
464 + if (workInProgress == null) {
465 + throw Error('workInProgress is ' + workInProgress + " but it can't be");
466 + }
467 + }
468 +
469 workInProgress.childExpirationTime = current.childExpirationTime;
470 workInProgress.expirationTime = current.expirationTime;
471
packages/shared/ReactFeatureFlags.js
+3
@@ -105,6 +105,9 @@ export const deferPassiveEffectCleanupDuringUnmount = false;
105 // a deprecated pattern we want to get rid of in the future
106 export const warnAboutSpreadingKeyToJSX = false;
107
108 +// Internal-only attempt to debug a React Native issue. See D20130868.
109 +export const throwEarlyForMysteriousError = false;
110 +
111 // --------------------------
112 // Future APIs to be deprecated
113 // --------------------------
packages/shared/forks/ReactFeatureFlags.native-fb.js
+3
@@ -50,6 +50,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
50 export const enableModernEventSystem = false;
51 export const warnAboutSpreadingKeyToJSX = false;
52
53 +// Internal-only attempt to debug a React Native issue. See D20130868.
54 +export const throwEarlyForMysteriousError = true;
55 +
56 // Only used in www builds.
57 export function addUserTimingListener() {
58 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.native-oss.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.persistent.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.testing.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.testing.www.js
+3
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
45 export const enableModernEventSystem = false;
46 export const warnAboutSpreadingKeyToJSX = false;
47
48 +// Internal-only attempt to debug a React Native issue. See D20130868.
49 +export const throwEarlyForMysteriousError = false;
50 +
51 // Only used in www builds.
52 export function addUserTimingListener() {
53 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.www.js
+3
@@ -99,6 +99,9 @@ export const warnUnstableRenderSubtreeIntoContainer = false;
99
100 export const enableModernEventSystem = false;
101
102 +// Internal-only attempt to debug a React Native issue. See D20130868.
103 +export const throwEarlyForMysteriousError = false;
104 +
105 // Flow magic to verify the exports of this file match the original version.
106 // eslint-disable-next-line no-unused-vars
107 type Check<_X, Y: _X, X: Y = _X> = null;