facebook/relay · error
Relay Environment Configuration Error (dev only): `@required
Error message
Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `relayFieldLogger`.
What it means
@required(action: LOG) fields report missing-field events through the environment's relayFieldLogger. The default logger deliberately throws in __DEV__ when such an event arrives, telling the developer the environment was never configured with a real logger; in production it silently no-ops.
Source
Thrown at packages/relay-runtime/store/defaultRelayFieldLogger.js:18
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall relay
*/
'use strict';
import type {RelayFieldLogger} from './RelayStoreTypes';
const defaultRelayFieldLogger: RelayFieldLogger = event => {
if (__DEV__ && event.kind === 'missing_required_field.log') {
throw new Error(
'Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `relayFieldLogger`.',
);
}
};
module.exports = defaultRelayFieldLogger;
View on GitHub (pinned to 668b1b85e0)
Solutions
- Pass relayFieldLogger to the Relay Environment constructor with a handler for missing_required_field.log events
- Import and wire defaultRelayFieldLogger replacement, e.g. from relay-runtime/store/RelayDefaultFieldLogger (or your own)
- If the throw is intentional dev noise, confirm __DEV__ flag and add the logger before data reads
- Remove or downgrade @required(action: LOG) if logging isn't actually wanted
Example fix
// before
const env = new Environment({network, store});
// after
const env = new Environment({network, store, relayFieldLogger: myFieldLogger}); Defensive patterns
Strategy: validation
Validate before calling
if (__DEV__ && env.getNetwork == null) {/*...*/}
// Before reading data in dev, assert the environment was built with a field logger:
console.assert(envConfig.relayFieldLogger != null, 'Configure relayFieldLogger for @required(action: LOG)'); Type guard
null
Try / catch
try {
lookupData();
} catch (e) {
if (String(e.message).includes('relayFieldLogger')) {
console.error('Environment missing relayFieldLogger; configure it for @required(action: LOG)');
} else throw e;
} Prevention
- Always pass relayFieldLogger when constructing Environment objects, including tests/Storybook
- Centralize Environment creation in one factory
- Grep for @required(action: LOG) when adding new environments
- Keep dev and prod environment setups in sync
When it happens
Trigger: Reading a snapshot where a @required(action: LOG) field is missing while the Environment was created without passing relayFieldLogger to the constructor (and the app is running in development).
Common situations: Creating a new Environment in tests or Storybook with only a network/store and forgetting relayFieldLogger; adding @required(action: LOG) to a fragment without updating environment setup; dev-only builds surfacing what production hides.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- BabelPluginRelay: Expected plugin context to include "types"
- Babel state is missing expected file name
- RelayObservable: Expected pollInterval to be positive, got:
- BabelPluginRelay: Expected exactly one definition per graphq
- BabelPluginRelay: Expected a fragment, mutation, query, or s
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/6539f64048505363.
Report an issue: GitHub.