quasarframework/quasar · warning

Tried add listener but no event specified.

Error message

Tried add listener but no event specified.

What it means

BexBridge.on(event, callback) was called with an empty/undefined/falsy event name. The bridge warns and skips registering the listener instead of throwing.

Source

Thrown at app-vite/exports/bex/private/bex-bridge.js:263

        'Tried to disconnect from the background script but the port was not connected'
      )
    }

    this.portMap.background.disconnect()
    delete this.portMap.background
    this.isConnected = false
    // an explicit disconnect also opts out of the auto-reconnect behavior
    this.#wasConnected = false
    return Promise.resolve()
  }

  /**
   * @param {string} event
   * @param {(message: Message) => void} callback
   */
  on(event, callback) {
    if (!event) {
      this.warn('Tried add listener but no event specified.')
      return
    }

    if (typeof callback !== 'function') {
      this.warn('Tried add listener but no valid callback function specified.')
      return
    }

    const target = (this.listeners[event] ||= [])
    target.push({ type: 'on', callback })
    this.log(`Added a listener for event: "${event}".`)
  }

  /**
   * @param {string} event
   * @param {(message: Message) => void} callback
   */
  once(event, callback) {

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Pass a non-empty string as the first argument to on().
  2. Check that the event-name constant is actually imported/defined (undefined imports yield falsy names).
  3. Log the event argument before calling to confirm its value.

Example fix

// before
bridge.on(EVENT_NAME, handler) // EVENT_NAME undefined
// after
if (typeof EVENT_NAME !== 'string' || EVENT_NAME.length === 0) {
  throw new Error('EVENT_NAME must be a non-empty string')
}
bridge.on(EVENT_NAME, handler)
Defensive patterns

Strategy: validation

Validate before calling

if (typeof event !== 'string' || event.length === 0) {
  throw new TypeError('bridge.on requires a non-empty event name')
}
bridge.on(event, callback)

Type guard

const isValidEventName = (e) => typeof e === 'string' && e.trim().length > 0

Prevention

When it happens

Trigger: bridge.on(undefined, fn), bridge.on('', fn), or passing a variable that is not yet assigned as the event name.

Common situations: Event name read from config/env that is missing; typo where the event constant is undefined due to a circular import or wrong import path.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30). Data as JSON: /api/errors/d9736d2556ad8634. Report an issue: GitHub.