{"record":{"id":"f7dedaacd796cc61","repo":"quasarframework/quasar","slug":"failed-to-forward-message-of-type-packet-type","errorCode":null,"errorMessage":"Failed to forward message of type \"${packet.type}\" from \"${packet.from}\" to \"${packet.to}\".","messagePattern":"Failed to forward message of type \"(.+?)\" from \"(.+?)\" to \"(.+?)\"\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app-vite/exports/bex/private/bex-bridge.js","lineNumber":656,"sourceCode":"      this.log(\n        'Received a message that does not appear to be emitted by a Quasar bridge or is malformed.',\n        packet\n      )\n      return\n    }\n\n    this.log(\n      `Received message of type \"${packet.type}\" from \"${packet.from}\".`,\n      packet\n    )\n\n    /**\n     * if the packet is not addressed to this bridge\n     * then forward it to the target\n     */\n    if (packet.to !== this.portName) {\n      this.#sendPacket(packet).catch(err => {\n        this.warn(\n          `Failed to forward message of type \"${packet.type}\" from \"${packet.from}\" to \"${packet.to}\".`,\n          err\n        )\n\n        this.#sendMessage({\n          id: packet.id,\n          to: packet.from,\n          messageType: 'event-response',\n          messageProps: {\n            error: {\n              message: err.message,\n              stack: err.stack || 'no stack available'\n            },\n            quiet: true\n          }\n        })\n      })\n      return","sourceCodeStart":638,"sourceCodeEnd":674,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/app-vite/exports/bex/private/bex-bridge.js#L638-L674","documentation":"When the bridge receives a packet addressed to a different port (packet.to !== this.portName), it forwards it via #sendPacket to the target. If that forwarded postMessage fails, it warns with the packet type/from/to details and sends a failure response back to the original sender.","triggerScenarios":"A message arrives at a bridge whose port is not the addressee and the forwarding #sendPacket (port.postMessage) throws — usually the target port is disconnected, its counterpart context closed, or the port was never opened.","commonSituations":"Content script or popup closed while a message was in flight; dev server hot-reload restarted the extension page killing ports; message routed to a listener name that doesn't exist in the target context.","solutions":["Ensure the receiving context (target port) is open and has created its bridge before sending","Re-check that the `to` address matches an active bridge port name","Reopen/reload the closed context (popup, content script tab) and retry the message","Handle the failure response sent back to the sender (packet with error) gracefully"],"exampleFix":"// before\nbridge.send('do.work', payload) // target page may be closed\n// after\ntry {\n  const res = await bridge.send('do.work', payload)\n} catch (err) {\n  console.warn('Receiver unavailable, retry later', err)\n}","handlingStrategy":"retry","validationCode":"// ensure the target context has an active bridge before routing\n// sender side: verify the addressee is reachable\nfunction canRouteTo(knownPorts, to) {\n  return knownPorts.includes(to)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await bridge.send('target.event', payload)\n} catch (err) {\n  // receiver closed; recreate bridge/ports then retry once\n  await reopenBridge()\n  await bridge.send('target.event', payload)\n}","preventionTips":["Only send messages to contexts you know are alive (check port readiness)","Recreate ports after MV3 service-worker restarts and page reloads","Handle the error response packet the bridge sends back to the sender","Avoid messaging popups/options pages that may close at any moment"],"tags":["bex","message-routing","port"],"backgroundTag":"dead-port-forward","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}