quasarframework/quasar · warning

Tried to remove listener but the callback specified is not a

Error message

Tried to remove listener but the callback specified is not a function.

What it means

BexBridge.off(event, callback) was called with a callback that is not a function (and not undefined, which means remove-all). The bridge warns and removes nothing, so the listener stays attached and keeps firing.

Source

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

        `Tried to remove listener for "${event}" event but there is no such listener attached.`
      )
      return
    }

    if (callback === void 0) {
      if (event.startsWith('@quasar:')) {
        // ensure we don't remove internal listeners
        this.listeners[event] = [list[0]]
      } else {
        delete this.listeners[event]
      }

      this.log(`Stopped listening for "${event}".`)
      return
    }

    if (typeof callback !== 'function') {
      this.warn(
        'Tried to remove listener but the callback specified is not a function.'
      )
      return
    }

    const liveEvents = list.filter(entry => entry.callback !== callback)

    if (liveEvents.length !== 0) {
      this.listeners[event] = liveEvents
      this.log(`Removed a listener for: "${event}".`)
    } else {
      delete this.listeners[event]
      this.log(`Stopped listening for: "${event}".`)
    }
  }

  /**
   * @param {{ event: string, to: string, payload: any } | undefined} param

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Pass the exact same function reference given to on()/once() as the second argument.
  2. If you intend to remove all listeners for the event, omit the callback argument instead.
  3. Store the handler reference (don't create a new arrow function) so it can be removed later.

Example fix

// before
bridge.on('tick', () => update())
bridge.off('tick', () => update()) // new reference, and removal path
// after
const onTick = () => update()
bridge.on('tick', onTick)
bridge.off('tick', onTick)
Defensive patterns

Strategy: type-guard

Type guard

const canOff = (event, cb) =>
  typeof event === 'string' && event.length > 0 &&
  (cb === undefined || typeof cb === 'function')

Prevention

When it happens

Trigger: bridge.off('event', someNonFunction) — e.g. passing the handler's return value, an event object, or a bound-but-wrong argument order.

Common situations: Argument order confusion (off(callback, event)); passing a method reference that got wrapped/replaced; cleanup code receiving the wrong variable scope.

Related errors


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