Freika/dawarich · warning

[MapChannel] Failed to subscribe to points channel:

Error message

[MapChannel] Failed to subscribe to points channel:

What it means

With live mode enabled, the map subscribes to PointsChannel to receive newly imported points in real time. Subscription creation is wrapped in try/catch; a synchronous throw logs this warning and the map keeps working — it just stops receiving live points until reload. The adjacent else branch logs that live mode was disabled, so this warning specifically means live mode WAS on and the subscribe threw.

Source

Thrown at app/javascript/maps_maplibre/channels/map_channel.js:91

          console.log("PointsChannel connected")
          callbacks.connected?.("points")
        },

        disconnected() {
          console.log("PointsChannel disconnected")
          callbacks.disconnected?.("points")
        },

        received(data) {
          console.log("PointsChannel received:", data)
          callbacks.received?.({
            type: "new_point",
            point: data,
          })
        },
      })
    } catch (error) {
      console.warn("[MapChannel] Failed to subscribe to points channel:", error)
    }
  } else {
    console.log(
      "[MapChannel] Live mode disabled, not subscribing to PointsChannel",
    )
  }

  // Note: NotificationsChannel is handled by notifications_controller.js in the navbar
  // Creating a second subscription here causes issues with ActionCable

  // Subscribe to tracks channel for real-time track updates
  try {
    subscriptions.tracks = consumer.subscriptions.create("TracksChannel", {
      connected() {
        console.log("TracksChannel connected")
        callbacks.connected?.("tracks")
      },

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Filter the Network tab by WS: the /cable connection should be 101 Switching Protocols
  2. Fix the proxy to pass Connection/Upgrade headers and permit long-lived connections for the cable path
  3. Confirm the cable URL uses wss:// when the page is served over https
  4. Reload after backend channel renames and cache-bust stale JS bundles

Example fix

// before
subscriptions.points = consumer.subscriptions.create("PointsChannel", { ...handlers })
// after
try {
  subscriptions.points = consumer.subscriptions.create("PointsChannel", {
    rejected() { console.warn("[MapChannel] Points channel rejected subscription") },
    ...handlers,
  })
} catch (error) {
  console.warn("[MapChannel] Failed to subscribe to points channel:", error)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!enableLiveMode) return
if (!consumer || typeof consumer.subscriptions?.create !== "function") return

Try / catch

try {
  subscriptions.points = consumer.subscriptions.create("PointsChannel", {
    rejected() { console.warn("[MapChannel] Points channel rejected subscription") },
    ...handlers,
  })
} catch (error) {
  console.warn("[MapChannel] Failed to subscribe to points channel:", error)
  // Live points are an enhancement; the map remains fully functional without them
}

Prevention

When it happens

Trigger: enableLiveMode true but the WebSocket to /cable cannot be established (proxy blocks the upgrade, wrong mount path); consumer in a failed/reconnecting state that throws on create; a stale bundle using a channel identifier the backend renamed; mixed content with the page on https and the cable URL on ws://.

Common situations: Self-hosted Dawarich behind nginx/Caddy without WebSocket upgrade config for /cable; TLS terminated at a proxy while ActionCable still advertises ws://; deploys renaming PointsChannel; mobile networks killing idle sockets so later subscribe attempts fail.

Related errors


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