facebook/react · error · TypeError

Bridge event names must be non-empty strings.

Error message

Bridge event names must be non-empty strings.

What it means

The Bridge validates every outgoing message name in send(): it must be a non-empty string before the message is queued for the wall. The TypeError is thrown synchronously, which almost always means a computed/dynamic event name evaluated to undefined or '' — i.e. a bug in the calling code, not in the transport.

Source

Thrown at packages/react-devtools-shared/src/bridge.js:373

    super.addListener(event, listener);
  }

  emit<Event: $Keys<EventEmitterEvents<IncomingEvents>>>(
    event: Event,
    ...args: EventEmitterEvents<IncomingEvents>[Event]
  ): void {
    this._assertNotShutdown('emit an event');
    super.emit(event, ...args);
  }

  send<EventName: $Keys<OutgoingEvents>>(
    event: EventName,
    payload?: OutgoingEvents[EventName],
  ): void {
    this._assertNotShutdown('send a message');

    if (typeof event !== 'string' || event.length === 0) {
      throw new TypeError('Bridge event names must be non-empty strings.');
    }

    // When we receive a message:
    // - we add it to our queue of messages to be sent
    // - if there hasn't been a message recently, we set a timer for 0 ms in
    //   the future, allowing all messages created in the same tick to be sent
    //   together
    // - if there *has* been a message flushed in the last BATCH_DURATION ms
    //   (or we're waiting for our setTimeout-0 to fire), then _timeoutID will
    //   be set, and we'll simply add to the queue and wait for that
    this._messageQueue.push({
      event,
      payload,
    });
    if (!this._scheduledFlush) {
      this._scheduledFlush = true;
      // $FlowFixMe[cannot-resolve-name]
      if (typeof devtoolsJestTestScheduler === 'function') {

View on GitHub (pinned to eafeac097b)

Solutions

  1. Pass a literal event name that exists in the OutgoingEvents map (e.g. 'inspectElement'), not a computed value.
  2. If the name is dynamic, validate it first: typeof event === 'string' && event.length > 0.
  3. Fix the source of the undefined/empty value — usually a typo, missing import, or incomplete lookup map.

Example fix

// before
const event = eventNameByKey[key]; // undefined for unknown keys
bridge.send(event, payload);

// after
const event = eventNameByKey[key];
if (typeof event === 'string' && event.length > 0) {
  bridge.send(event, payload);
}
Defensive patterns

Strategy: validation

Validate before calling

function isValidEventName(event) {
  return typeof event === 'string' && event.length > 0;
}
if (isValidEventName(eventName)) {
  bridge.send(eventName, payload);
}

Type guard

function isValidEventName(event) {
  return typeof event === 'string' && event.length > 0;
}

Prevention

When it happens

Trigger: Calling bridge.send(eventName, payload) where eventName is undefined, null, a number, or '' — e.g. a typo'd variable, a missing import, or a name built from a lookup map with no matching key.

Common situations: Refactors that rename bridge events but miss a dynamic sender; key maps that return undefined for new/renamed events; tests that pass mock payloads as the first argument by mistake.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/4982c0ef74517820. Report an issue: GitHub.