{"record":{"id":"4982c0ef74517820","repo":"facebook/react","slug":"bridge-event-names-must-be-non-empty-strings","errorCode":null,"errorMessage":"Bridge event names must be non-empty strings.","messagePattern":"Bridge event names must be non-empty strings\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-shared/src/bridge.js","lineNumber":373,"sourceCode":"    super.addListener(event, listener);\n  }\n\n  emit<Event: $Keys<EventEmitterEvents<IncomingEvents>>>(\n    event: Event,\n    ...args: EventEmitterEvents<IncomingEvents>[Event]\n  ): void {\n    this._assertNotShutdown('emit an event');\n    super.emit(event, ...args);\n  }\n\n  send<EventName: $Keys<OutgoingEvents>>(\n    event: EventName,\n    payload?: OutgoingEvents[EventName],\n  ): void {\n    this._assertNotShutdown('send a message');\n\n    if (typeof event !== 'string' || event.length === 0) {\n      throw new TypeError('Bridge event names must be non-empty strings.');\n    }\n\n    // When we receive a message:\n    // - we add it to our queue of messages to be sent\n    // - if there hasn't been a message recently, we set a timer for 0 ms in\n    //   the future, allowing all messages created in the same tick to be sent\n    //   together\n    // - if there *has* been a message flushed in the last BATCH_DURATION ms\n    //   (or we're waiting for our setTimeout-0 to fire), then _timeoutID will\n    //   be set, and we'll simply add to the queue and wait for that\n    this._messageQueue.push({\n      event,\n      payload,\n    });\n    if (!this._scheduledFlush) {\n      this._scheduledFlush = true;\n      // $FlowFixMe[cannot-resolve-name]\n      if (typeof devtoolsJestTestScheduler === 'function') {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/bridge.js#L355-L391","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a literal event name that exists in the OutgoingEvents map (e.g. 'inspectElement'), not a computed value.","If the name is dynamic, validate it first: typeof event === 'string' && event.length > 0.","Fix the source of the undefined/empty value — usually a typo, missing import, or incomplete lookup map."],"exampleFix":"// before\nconst event = eventNameByKey[key]; // undefined for unknown keys\nbridge.send(event, payload);\n\n// after\nconst event = eventNameByKey[key];\nif (typeof event === 'string' && event.length > 0) {\n  bridge.send(event, payload);\n}","handlingStrategy":"validation","validationCode":"function isValidEventName(event) {\n  return typeof event === 'string' && event.length > 0;\n}\nif (isValidEventName(eventName)) {\n  bridge.send(eventName, payload);\n}","typeGuard":"function isValidEventName(event) {\n  return typeof event === 'string' && event.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Send literal event names from the events map; avoid computed names.","If names are dynamic, keep them in an exhaustive map keyed by literal unions so typos fail at typecheck.","Validate before send when interoperating with third-party senders."],"tags":["devtools","bridge","event-name","validation"],"backgroundTag":"invalid-event-name","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}