Freika/dawarich · warning

[MapChannel] Failed to subscribe to tracks channel:

Error message

[MapChannel] Failed to subscribe to tracks channel:

What it means

The map also subscribes to TracksChannel so finished background track calculations appear without a refresh. Like the other channel subscriptions, a synchronous throw during consumer.subscriptions.create is caught and logged with this warning; the map continues without live track updates, then setupMapChannels returns its unsubscribe handles.

Source

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

      },

      disconnected() {
        console.log("TracksChannel disconnected")
        callbacks.disconnected?.("tracks")
      },

      received(data) {
        console.log("TracksChannel received:", data)
        callbacks.received?.({
          type: "track_update",
          action: data.action,
          track: data.track,
          track_id: data.track_id,
        })
      },
    })
  } catch (error) {
    console.warn("[MapChannel] Failed to subscribe to tracks channel:", error)
  }

  return {
    subscriptions,
    unsubscribeAll() {
      Object.values(subscriptions).forEach((sub) => {
        sub?.unsubscribe()
      })
    },
  }
}

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Verify the /cable WebSocket connects (101 status) in the Network tab
  2. Align the channel identifier string with the Rails channel class name after upgrades
  3. Ensure proxy WebSocket upgrade configuration covers the cable mount path
  4. Cache-bust the JS bundle after backend channel changes

Example fix

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

Strategy: try-catch

Validate before calling

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

Try / catch

try {
  subscriptions.tracks = consumer.subscriptions.create("TracksChannel", {
    rejected() { console.warn("[MapChannel] Tracks channel rejected subscription") },
    ...handlers,
  })
} catch (error) {
  console.warn("[MapChannel] Failed to subscribe to tracks channel:", error)
  // Track updates simply stop being live; manual refresh still works
}

Prevention

When it happens

Trigger: Cable endpoint unreachable or blocked by the proxy; consumer in a bad state throwing on create; the TracksChannel identifier string not matching the Rails channel after a rename or namespacing change; subscription attempted while a previous cable connection is mid-reconnect and failing.

Common situations: WebSocket-incompatible proxies in front of self-hosted instances; backend upgrades renaming TracksChannel; authorization changes rejecting subscription creation; stale cached assets after deploy.

Related errors


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