Skip to content

Commit

Permalink
Add feature flag to log missing data using invariant in prod
Browse files Browse the repository at this point in the history
Summary:
* Add feature flag to log missing data using invariant in prod
* This (maybe) will allow us to confirm a hypothesis about what is occurring, which is that (at least certain) MIDs are preceded by this event occuring.
* Do not turn on that feature flag, yet

Reviewed By: tyao1

Differential Revision: D43911595

fbshipit-source-id: 57056d80f6efdfd7ff808cd4f9e0cffb2ece79c3
  • Loading branch information
Robert Balicki authored and facebook-github-bot committed Mar 21, 2023
1 parent cc478a6 commit 3073f1e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {getQueryResourceForEnvironment} = require('../QueryResource');
const invariant = require('invariant');
const {
__internal: {fetchQuery: fetchQueryInternal},
RelayFeatureFlags,
createOperationDescriptor,
getPendingOperationsForFragment,
getSelector,
Expand Down Expand Up @@ -268,7 +269,7 @@ function readFragmentInternal_REACT_CACHE(
data = state.snapshots.map(s => s.data);
}

if (__DEV__) {
if (RelayFeatureFlags.LOG_MISSING_RECORDS_IN_PROD || __DEV__) {
if (
fragmentRef != null &&
(data === undefined ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const invariant = require('invariant');
const {useDebugValue, useEffect, useMemo, useRef, useState} = require('react');
const {
__internal: {fetchQuery: fetchQueryInternal},
RelayFeatureFlags,
areEqualSelectors,
createOperationDescriptor,
getPendingOperationsForFragment,
Expand Down Expand Up @@ -565,7 +566,7 @@ function useFragmentInternal_REACT_CACHE(
data = state.snapshot.data;
}

if (__DEV__) {
if (RelayFeatureFlags.LOG_MISSING_RECORDS_IN_PROD || __DEV__) {
if (
fragmentRef != null &&
(data === undefined ||
Expand Down
4 changes: 2 additions & 2 deletions packages/react-relay/relay-hooks/useFragmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const {getFragmentResourceForEnvironment} = require('./FragmentResource');
const useRelayEnvironment = require('./useRelayEnvironment');
const useUnsafeRef_DEPRECATED = require('./useUnsafeRef_DEPRECATED');
const {useEffect, useState} = require('react');
const {getFragmentIdentifier} = require('relay-runtime');
const {RelayFeatureFlags, getFragmentIdentifier} = require('relay-runtime');
const warning = require('warning');

type ReturnType<TFragmentData: mixed> = {
Expand Down Expand Up @@ -99,7 +99,7 @@ function useFragmentNode<TFragmentData: mixed>(
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [environment, fragmentIdentifier]);

if (__DEV__) {
if (RelayFeatureFlags.LOG_MISSING_RECORDS_IN_PROD || __DEV__) {
if (
fragmentRef != null &&
(fragmentResult.data === undefined ||
Expand Down
2 changes: 2 additions & 0 deletions packages/relay-runtime/util/RelayFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type FeatureFlags = {
USE_REACT_CACHE: boolean,
USE_REACT_CACHE_LEGACY_TIMEOUTS: boolean,
ENABLE_QUERY_RENDERER_SET_STATE_PREVENTION: boolean,
LOG_MISSING_RECORDS_IN_PROD: boolean,
};

const RelayFeatureFlags: FeatureFlags = {
Expand All @@ -51,6 +52,7 @@ const RelayFeatureFlags: FeatureFlags = {
USE_REACT_CACHE: false,
USE_REACT_CACHE_LEGACY_TIMEOUTS: true,
ENABLE_QUERY_RENDERER_SET_STATE_PREVENTION: false,
LOG_MISSING_RECORDS_IN_PROD: false,
};

module.exports = RelayFeatureFlags;

0 comments on commit 3073f1e

Please sign in to comment.