Skip to content

Commit 4ee592e

Browse files
authored
Add an early invariant to debug a mystery crash (#18159)
1 parent 7ea4e41 commit 4ee592e

10 files changed

+40
-0
lines changed

packages/react-reconciler/src/ReactFiber.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
enableUserTimingAPI,
3535
enableScopeAPI,
3636
enableBlocksAPI,
37+
throwEarlyForMysteriousError,
3738
} from 'shared/ReactFeatureFlags';
3839
import {NoEffect, Placement} from 'shared/ReactSideEffectTags';
3940
import {ConcurrentRoot, BlockingRoot} from 'shared/ReactRootTags';
@@ -453,6 +454,18 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
453454
}
454455
}
455456

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+
456469
workInProgress.childExpirationTime = current.childExpirationTime;
457470
workInProgress.expirationTime = current.expirationTime;
458471

packages/shared/ReactFeatureFlags.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ export const deferPassiveEffectCleanupDuringUnmount = false;
105105
// a deprecated pattern we want to get rid of in the future
106106
export const warnAboutSpreadingKeyToJSX = false;
107107

108+
// Internal-only attempt to debug a React Native issue. See D20130868.
109+
export const throwEarlyForMysteriousError = false;
110+
108111
// --------------------------
109112
// Future APIs to be deprecated
110113
// --------------------------

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
5050
export const enableModernEventSystem = false;
5151
export const warnAboutSpreadingKeyToJSX = false;
5252

53+
// Internal-only attempt to debug a React Native issue. See D20130868.
54+
export const throwEarlyForMysteriousError = true;
55+
5356
// Only used in www builds.
5457
export function addUserTimingListener() {
5558
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.persistent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.testing.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.testing.www.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const runAllPassiveEffectDestroysBeforeCreates = false;
4545
export const enableModernEventSystem = false;
4646
export const warnAboutSpreadingKeyToJSX = false;
4747

48+
// Internal-only attempt to debug a React Native issue. See D20130868.
49+
export const throwEarlyForMysteriousError = false;
50+
4851
// Only used in www builds.
4952
export function addUserTimingListener() {
5053
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ export const warnUnstableRenderSubtreeIntoContainer = false;
9999

100100
export const enableModernEventSystem = false;
101101

102+
// Internal-only attempt to debug a React Native issue. See D20130868.
103+
export const throwEarlyForMysteriousError = false;
104+
102105
// Flow magic to verify the exports of this file match the original version.
103106
// eslint-disable-next-line no-unused-vars
104107
type Check<_X, Y: _X, X: Y = _X> = null;

0 commit comments

Comments
 (0)