{"record":{"id":"9b9fa60741606606","repo":"Freika/dawarich","slug":"realtime-controller-recent-point-layer-not-found","errorCode":null,"errorMessage":"[Realtime Controller] Recent point layer not found","messagePattern":"\\[Realtime Controller\\] Recent point layer not found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/controllers/maps/maplibre_realtime_controller.js","lineNumber":274,"sourceCode":"  }\n\n  // Note: Notifications are handled by notifications_controller.js in the navbar\n\n  /**\n   * Update the recent point marker\n   * This marker is always visible in live mode, independent of points layer visibility\n   */\n  updateRecentPoint(longitude, latitude, properties = {}) {\n    const mapsController = this.mapsV2Controller\n    if (!mapsController) {\n      console.warn(\"[Realtime Controller] Maps controller not found\")\n      return\n    }\n\n    const recentPointLayer =\n      mapsController.layerManager?.getLayer(\"recentPoint\")\n    if (!recentPointLayer) {\n      console.warn(\"[Realtime Controller] Recent point layer not found\")\n      return\n    }\n\n    if (this.liveModeEnabled) {\n      recentPointLayer.show()\n      recentPointLayer.updateRecentPoint(longitude, latitude, properties)\n    }\n  }\n\n  /**\n   * Zoom map to a specific point\n   */\n  zoomToPoint(longitude, latitude) {\n    const mapsController = this.mapsV2Controller\n    if (!mapsController || !mapsController.map) {\n      console.warn(\"[Realtime Controller] Map not available for zooming\")\n      return\n    }","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/controllers/maps/maplibre_realtime_controller.js#L256-L292","documentation":"updateRecentPoint resolved the Maps V2 controller but layerManager.getLayer(\"recentPoint\") returned undefined, so the always-on live marker cannot be updated. LayerManager creates the recentPoint layer lazily (layer_manager.js:503 creates layers.recentPointLayer on first ensure), so this fires when that initialization path has not run yet or the layer id differs. The broadcast is dropped with a warning.","triggerScenarios":"A realtime broadcast reaches updateRecentPoint before the LayerManager's lazy recentPoint-layer creation has run (map still initializing), or the layer was registered/cleared under a key other than \"recentPoint\" after a refactor.","commonSituations":"Fast GPS updates immediately after page load while MapLibre is still initializing; toggling live mode off and on during map init; refactors renaming the layer registry key from recentPoint to something else while the realtime controller still queries the old id.","solutions":["Trigger the lazy creation path (the ensure/init routine in layer_manager.js around line 503) before or on first realtime update, e.g. call the ensure method from updateRecentPointLayerVisibility when live mode is enabled.","Delay channel subscription until the map fires its ready/load event so the layer registry is fully populated first.","Confirm the registry key is exactly \"recentPoint\" wherever the layer is created."],"exampleFix":"// before\nconst recentPointLayer = mapsController.layerManager?.getLayer(\"recentPoint\")\nif (!recentPointLayer) {\n  console.warn(\"[Realtime Controller] Recent point layer not found\")\n  return\n}\n\n// after\nmapsController.layerManager?.ensureRecentPointLayer?.()\nconst recentPointLayer = mapsController.layerManager?.getLayer(\"recentPoint\")\nif (!recentPointLayer) {\n  console.warn(\"[Realtime Controller] Recent point layer not found\")\n  return\n}","handlingStrategy":"validation","validationCode":"const lm = mapsController.layerManager\nif (!lm?.getLayer(\"recentPoint\")) lm?.ensureRecentPointLayer?.()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trigger lazy layer creation before first use in live mode, not only on broadcast.","Initialize all realtime-consumed layers during map setup when live mode is enabled at page load."],"tags":["maplibre","actioncable","layer-not-found","realtime","lazy-init"],"backgroundTag":"map-layer-not-initialized","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}