{"record":{"id":"664f172af154e1d7","repo":"quasarframework/quasar","slug":"tried-add-listener-but-no-valid-callback-function","errorCode":null,"errorMessage":"Tried add listener but no valid callback function specified.","messagePattern":"Tried add listener but no valid callback function specified\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app-vite/exports/bex/private/bex-bridge.js","lineNumber":268,"sourceCode":"    delete this.portMap.background\n    this.isConnected = false\n    // an explicit disconnect also opts out of the auto-reconnect behavior\n    this.#wasConnected = false\n    return Promise.resolve()\n  }\n\n  /**\n   * @param {string} event\n   * @param {(message: Message) => void} callback\n   */\n  on(event, callback) {\n    if (!event) {\n      this.warn('Tried add listener but no event specified.')\n      return\n    }\n\n    if (typeof callback !== 'function') {\n      this.warn('Tried add listener but no valid callback function specified.')\n      return\n    }\n\n    const target = (this.listeners[event] ||= [])\n    target.push({ type: 'on', callback })\n    this.log(`Added a listener for event: \"${event}\".`)\n  }\n\n  /**\n   * @param {string} event\n   * @param {(message: Message) => void} callback\n   */\n  once(event, callback) {\n    if (!event) {\n      this.warn('Tried add listener but no event specified.')\n      return\n    }\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/exports/bex/private/bex-bridge.js#L250-L286","documentation":"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.","triggerScenarios":"bridge.on('my-event'), bridge.on('my-event', undefined), or passing something like an object/array/string as the second argument.","commonSituations":"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.","solutions":["Pass a function as the second argument to on().","Verify the handler import is correct and not undefined.","If subscribing conditionally, still supply a no-op function rather than omitting the argument."],"exampleFix":"// before\nbridge.on('message', this.handler) // this.handler is undefined\n// after\nconst handler = this.handler ?? (() => {})\nbridge.on('message', handler)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const isFn = (f) => typeof f === 'function'\nif (isFn(callback)) bridge.on(event, callback)","tryCatchPattern":null,"preventionTips":["Always pass a function reference as the 2nd argument.","Verify handler imports resolve to defined functions.","Use no-op fallbacks for optional handlers: (handler ?? (() => {}))."],"tags":["bex","extension","invalid-argument","callback"],"backgroundTag":"callback-not-a-function","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}