Freika/dawarich · warning

[Realtime Controller] Recent point layer not found

Error message

[Realtime Controller] Recent point layer not found

What it means

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.

Source

Thrown at app/javascript/controllers/maps/maplibre_realtime_controller.js:274

  }

  // Note: Notifications are handled by notifications_controller.js in the navbar

  /**
   * Update the recent point marker
   * This marker is always visible in live mode, independent of points layer visibility
   */
  updateRecentPoint(longitude, latitude, properties = {}) {
    const mapsController = this.mapsV2Controller
    if (!mapsController) {
      console.warn("[Realtime Controller] Maps controller not found")
      return
    }

    const recentPointLayer =
      mapsController.layerManager?.getLayer("recentPoint")
    if (!recentPointLayer) {
      console.warn("[Realtime Controller] Recent point layer not found")
      return
    }

    if (this.liveModeEnabled) {
      recentPointLayer.show()
      recentPointLayer.updateRecentPoint(longitude, latitude, properties)
    }
  }

  /**
   * Zoom map to a specific point
   */
  zoomToPoint(longitude, latitude) {
    const mapsController = this.mapsV2Controller
    if (!mapsController || !mapsController.map) {
      console.warn("[Realtime Controller] Map not available for zooming")
      return
    }

View on GitHub (pinned to 97fad417c5)

Solutions

  1. 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.
  2. Delay channel subscription until the map fires its ready/load event so the layer registry is fully populated first.
  3. Confirm the registry key is exactly "recentPoint" wherever the layer is created.

Example fix

// before
const recentPointLayer = mapsController.layerManager?.getLayer("recentPoint")
if (!recentPointLayer) {
  console.warn("[Realtime Controller] Recent point layer not found")
  return
}

// after
mapsController.layerManager?.ensureRecentPointLayer?.()
const recentPointLayer = mapsController.layerManager?.getLayer("recentPoint")
if (!recentPointLayer) {
  console.warn("[Realtime Controller] Recent point layer not found")
  return
}
Defensive patterns

Strategy: validation

Validate before calling

const lm = mapsController.layerManager
if (!lm?.getLayer("recentPoint")) lm?.ensureRecentPointLayer?.()

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/9b9fa60741606606. Report an issue: GitHub.