quasarframework/quasar · warning

Tried add listener but no valid callback function specified.

Error message

Tried add listener but no valid callback function specified.

What it means

BexBridge.on(event, callback) received a callback that is not a function. The bridge warns and does not register the listener, so messages for that event will silently never be handled.

Source

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

    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) {
    if (!event) {
      this.warn('Tried add listener but no event specified.')
      return
    }

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Pass a function as the second argument to on().
  2. Verify the handler import is correct and not undefined.
  3. If subscribing conditionally, still supply a no-op function rather than omitting the argument.

Example fix

// before
bridge.on('message', this.handler) // this.handler is undefined
// after
const handler = this.handler ?? (() => {})
bridge.on('message', handler)
Defensive patterns

Strategy: type-guard

Type guard

const isFn = (f) => typeof f === 'function'
if (isFn(callback)) bridge.on(event, callback)

Prevention

When it happens

Trigger: bridge.on('my-event'), bridge.on('my-event', undefined), or passing something like an object/array/string as the second argument.

Common situations: Misremembering the signature (passing options as 2nd arg); a handler imported as undefined due to wrong named import; refactoring that removed the handler but left the registration.

Related errors


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