{"record":{"id":"d218e39de2bb8c92","repo":"quasarframework/quasar","slug":"error-while-triggering-listener-plural-for-event","errorCode":null,"errorMessage":"Error while triggering listener${plural} for event: \"${message.event}\".","messagePattern":"Error while triggering listener(.+?) for event: \"(.+?)\"\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app-vite/exports/bex/private/bex-bridge.js","lineNumber":589,"sourceCode":"      }\n    )\n\n    let responsePayload\n    // oxlint-disable-next-line unicorn/no-useless-spread\n    for (const { type, callback } of [...list]) {\n      if (type === 'once') {\n        this.off(message.event, callback)\n      }\n\n      try {\n        if (responsePayload === void 0) {\n          const value = callback(message)\n          responsePayload = value instanceof Promise ? await value : value\n        } else {\n          callback(message)\n        }\n      } catch (err) {\n        this.warn(\n          `Error while triggering listener${plural} for event: \"${message.event}\".`,\n          {\n            error: err,\n            message,\n            listener: { type, callback }\n          }\n        )\n\n        throw err\n      }\n    }\n\n    return responsePayload\n  }\n\n  /**\n   * @param {string} portName\n   */","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/exports/bex/private/bex-bridge.js#L571-L607","documentation":"The bridge's #triggerMessageEvent invokes each registered listener for an incoming bex message event. If any listener callback throws (synchronously or via a rejected Promise), the bridge catches it and warns with this message, embedding the offending event name, the message payload and the failing listener, then continues dispatching.","triggerScenarios":"A callback registered via bridge.on('<event>', fn) throws or returns a rejected promise while handling an incoming message; also when multiple listeners exist and one of them fails.","commonSituations":"A listener dereferences undefined message payload fields, JSON-shaped data doesn't match expectations after a payload change, async listener hits a network error, or a bug introduced in an app-level listener during refactoring.","solutions":["Inspect the `error` field in the details object logged alongside the warning to find the actual exception","Add your own try/catch or .catch() inside the failing listener registered with bridge.on()","Validate the message payload shape in the listener before using it","Verify the event name and listener type matches what the other side actually sends"],"exampleFix":"// before\nbridge.on('my.event', async payload => {\n  const data = await fetch('/api', { body: JSON.stringify(payload) }).then(r => r.json())\n  return data.value\n})\n// after\nbridge.on('my.event', async payload => {\n  try {\n    const res = await fetch('/api', { body: JSON.stringify(payload) })\n    const data = await res.json()\n    return data.value\n  } catch (err) {\n    console.error('my.event handler failed', err)\n    return null\n  }\n})","handlingStrategy":"try-catch","validationCode":"// validate payload before registering/handling\nfunction isValidMessage(msg) {\n  return msg && typeof msg.event === 'string' && msg.payload !== undefined\n}","typeGuard":"function isBridgeMessage(msg) {\n  return (\n    typeof msg === 'object' && msg !== null &&\n    typeof msg.event === 'string' &&\n    'payload' in msg\n  )\n}","tryCatchPattern":"bridge.on('my.event', async payload => {\n  try {\n    if (!isBridgeMessage(payload)) throw new TypeError('bad payload')\n    return await handleMessage(payload)\n  } catch (err) {\n    console.error(`Listener for \"my.event\" failed`, err)\n    return null // don't let the rejection bubble into the bridge\n  }\n})","preventionTips":["Wrap every bridge.on() listener body in its own try/catch or .catch()","Validate message payload shape before dereferencing fields","Keep listeners pure of thrown errors; return explicit error values instead","Test listeners with malformed payloads to confirm graceful failure"],"tags":["bex","event-listener","callback"],"backgroundTag":"listener-callback-threw","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}