{"record":{"id":"b266b3f11d995643","repo":"Freika/dawarich","slug":"realtime-controller-maps-controller-not-found","errorCode":null,"errorMessage":"[Realtime Controller] Maps controller not found","messagePattern":"\\[Realtime Controller\\] Maps controller not found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/controllers/maps/maplibre_realtime_controller.js","lineNumber":173,"sourceCode":"  }\n\n  /**\n   * Get the maps--maplibre controller (on same element)\n   */\n  get mapsV2Controller() {\n    const element = this.element\n    const app = this.application\n    return app.getControllerForElementAndIdentifier(element, \"maps--maplibre\")\n  }\n\n  /**\n   * Handle new point\n   * Point data is broadcast as: [lat, lon, battery, altitude, timestamp, velocity, id, country_name]\n   */\n  handleNewPoint(pointData) {\n    const mapsController = this.mapsV2Controller\n    if (!mapsController) {\n      console.warn(\"[Realtime Controller] Maps controller not found\")\n      return\n    }\n\n    const [lat, lon, battery, altitude, timestamp, velocity, id, countryName] =\n      pointData\n\n    const pointsLayer = mapsController.layerManager?.getLayer(\"points\")\n    if (!pointsLayer) {\n      console.warn(\"[Realtime Controller] Points layer not found\")\n      return\n    }\n\n    const currentData = pointsLayer.data || {\n      type: \"FeatureCollection\",\n      features: [],\n    }\n    const features = [...(currentData.features || [])]\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/controllers/maps/maplibre_realtime_controller.js#L155-L191","documentation":"The realtime controller resolves the Maps V2 controller via application.getControllerForElementAndIdentifier(this.element, \"maps--maplibre\"), which returns null unless the realtime controller's element is the same element as, or a descendant of, the element carrying data-controller=\"maps--maplibre\". When an ActionCable \"new_point\" broadcast arrives and that lookup fails, the handler bails with this warning. It is a Stimulus controller-wiring/DOM-nesting problem, not a cable problem.","triggerScenarios":"An ActionCable new_point broadcast for the user's points channel arrives while (a) the realtime controller element sits outside the maps--maplibre element's subtree, (b) the maplibre controller has not yet connected (map still initializing), or (c) the identifier string was changed (file rename maps/maplibre_controller.js changes the default identifier to maps--maplibre).","commonSituations":"Moving the live-mode toggle / realtime wrapper div outside the map container in views; Turbo frame or morphdom re-render that detaches the map element; a broadcast that lands during page load before Stimulus connect() completes; renaming the controller file or setting a custom static identifier.","solutions":["Nest the realtime controller element inside the element with data-controller=\"maps--maplibre\" so getControllerForElementAndIdentifier can find it.","Defer channel subscription until the map controller signals readiness (e.g. subscribe on a custom map:ready event dispatched by maplibre_controller) so broadcasts cannot arrive before the controller exists.","If the controller file was moved/renamed, verify the identifier passed matches the path-derived name maps--maplibre (directory maps/ + file maplibre_controller.js)."],"exampleFix":"// before\n// <div data-controller=\"maps--maplibre-realtime\"> ... </div>\n// <div data-controller=\"maps--maplibre\"> map canvas </div>\n\n// after\n// <div data-controller=\"maps--maplibre\">\n//   <div data-controller=\"maps--maplibre-realtime\"> ... </div>\n//   map canvas\n// </div>","handlingStrategy":"validation","validationCode":"const ctrl = this.application.getControllerForElementAndIdentifier(\n  this.element,\n  \"maps--maplibre\",\n)\nif (!ctrl) return // do not subscribe yet","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Nest the realtime controller element inside the maps--maplibre element in every view that uses it.","Subscribe to ActionCable channels only after the map controller signals readiness, not in connect().","Treat controller-lookup failure as a wiring bug: assert it once at subscribe time rather than warning per broadcast."],"tags":["stimulus","actioncable","websockets","controller-lookup","realtime"],"backgroundTag":"stimulus-controller-not-found","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}