Freika/dawarich · warning
[MapChannel] Failed to subscribe to family channel:
Error message
[MapChannel] Failed to subscribe to family channel:
What it means
The map page subscribes to FamilyLocationsChannel inside a try/catch to receive live family-member locations. consumer.subscriptions.create throws synchronously when the consumer is in a bad state, the cable connection URL is wrong, or the channel identifier is malformed. When it throws, family live updates are unavailable for the session; points and tracks subscriptions still proceed.
Source
Thrown at app/javascript/maps_maplibre/channels/map_channel.js:65
},
disconnected() {
console.log("FamilyLocationsChannel disconnected")
callbacks.disconnected?.("family")
},
received(data) {
console.log("FamilyLocationsChannel received:", data)
callbacks.received?.({
type: "family_location",
member: data,
})
},
},
)
}
} catch (error) {
console.warn("[MapChannel] Failed to subscribe to family channel:", error)
}
// Subscribe to points channel for real-time point updates (only if live mode is enabled)
if (enableLiveMode) {
try {
subscriptions.points = consumer.subscriptions.create("PointsChannel", {
connected() {
console.log("PointsChannel connected")
callbacks.connected?.("points")
},
disconnected() {
console.log("PointsChannel disconnected")
callbacks.disconnected?.("points")
},
received(data) {
console.log("PointsChannel received:", data)View on GitHub (pinned to 97fad417c5)
Solutions
- Open /cable in the browser — it must not 404, and the WS upgrade should appear as 101 Switching Protocols in the Network tab
- Configure the proxy to pass Connection/Upgrade headers and allow long-lived connections for the cable path
- Ensure Rails allowed_request_origins includes the site origin and the cable URL uses wss:// when the page is https
- After backend deploys that touch channels, cache-bust stale JS bundles
Example fix
// before
subscriptions.family = consumer.subscriptions.create("FamilyLocationsChannel", { ...handlers })
// after
if (typeof consumer?.subscriptions?.create === "function") {
subscriptions.family = consumer.subscriptions.create("FamilyLocationsChannel", {
rejected() { console.warn("[MapChannel] Family channel rejected subscription") },
...handlers,
})
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!consumer || typeof consumer.subscriptions?.create !== "function") return
const familyEl = document.querySelector("[data-family-members-features-value]")
if (!familyEl) return // family feature disabled — skip the channel entirely Type guard
/** @param {unknown} c @returns {boolean} */
function isActionCableConsumer(c) {
return Boolean(
c &&
typeof c === "object" &&
typeof c.subscriptions?.create === "function"
)
} Try / catch
try {
subscriptions.family = consumer.subscriptions.create("FamilyLocationsChannel", {
rejected() { console.warn("[MapChannel] Family channel rejected subscription") },
...handlers,
})
} catch (error) {
console.warn("[MapChannel] Failed to subscribe to family channel:", error)
// Realtime family locations are an enhancement: keep the map usable without them
} Prevention
- Verify the WebSocket upgrade works for the cable endpoint in every environment — proxy configs differ
- Add rejected() callbacks to subscriptions; server-side rejections do not throw and are otherwise invisible
- Subscribe only when the corresponding feature-flag element exists in the DOM
When it happens
Trigger: ActionCable mount path changed server-side so the cable URL 404s; the WebSocket to /cable failing CORS or blocked by a proxy that does not upgrade; the family features element present in the DOM but the channel identifier string not matching the Rails channel; a stale cached JS bundle calling a renamed channel.
Common situations: Reverse proxies (nginx/traefik) not passing Upgrade/Connection headers for the cable path; dev served over https while the cable URL uses ws:// (mixed content); backend channel renames during upgrades; older bundles cached by the browser or CDN.
Related errors
- [MapChannel] Failed to subscribe to tracks channel:
- [MapChannel] ActionCable consumer not available
- [MapChannel] Failed to subscribe to points channel:
- [Realtime Controller] Maps controller not found
- [Realtime Controller] Points layer not found
AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21).
Data as JSON: /api/errors/bb66a0a08c58974d.
Report an issue: GitHub.