{"record":{"id":"d9736d2556ad8634","repo":"quasarframework/quasar","slug":"tried-add-listener-but-no-event-specified","errorCode":null,"errorMessage":"Tried add listener but no event specified.","messagePattern":"Tried add listener but no event specified\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app-vite/exports/bex/private/bex-bridge.js","lineNumber":263,"sourceCode":"        'Tried to disconnect from the background script but the port was not connected'\n      )\n    }\n\n    this.portMap.background.disconnect()\n    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) {","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/exports/bex/private/bex-bridge.js#L245-L281","documentation":"BexBridge.on(event, callback) was called with an empty/undefined/falsy event name. The bridge warns and skips registering the listener instead of throwing.","triggerScenarios":"bridge.on(undefined, fn), bridge.on('', fn), or passing a variable that is not yet assigned as the event name.","commonSituations":"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.","solutions":["Pass a non-empty string as the first argument to on().","Check that the event-name constant is actually imported/defined (undefined imports yield falsy names).","Log the event argument before calling to confirm its value."],"exampleFix":"// before\nbridge.on(EVENT_NAME, handler) // EVENT_NAME undefined\n// after\nif (typeof EVENT_NAME !== 'string' || EVENT_NAME.length === 0) {\n  throw new Error('EVENT_NAME must be a non-empty string')\n}\nbridge.on(EVENT_NAME, handler)","handlingStrategy":"validation","validationCode":"if (typeof event !== 'string' || event.length === 0) {\n  throw new TypeError('bridge.on requires a non-empty event name')\n}\nbridge.on(event, callback)","typeGuard":"const isValidEventName = (e) => typeof e === 'string' && e.trim().length > 0","tryCatchPattern":null,"preventionTips":["Define event names as exported constants.","Validate dynamic event names before subscribing.","Check for undefined imports from circular dependencies."],"tags":["bex","extension","missing-argument","event-listener"],"backgroundTag":"missing-required-argument","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}