{"record":{"id":"36e291ba5788922d","repo":"Freika/dawarich","slug":"mapchannel-failed-to-subscribe-to-points-channel","errorCode":null,"errorMessage":"[MapChannel] Failed to subscribe to points channel:","messagePattern":"\\[MapChannel\\] Failed to subscribe to points channel:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/maps_maplibre/channels/map_channel.js","lineNumber":91,"sourceCode":"          console.log(\"PointsChannel connected\")\n          callbacks.connected?.(\"points\")\n        },\n\n        disconnected() {\n          console.log(\"PointsChannel disconnected\")\n          callbacks.disconnected?.(\"points\")\n        },\n\n        received(data) {\n          console.log(\"PointsChannel received:\", data)\n          callbacks.received?.({\n            type: \"new_point\",\n            point: data,\n          })\n        },\n      })\n    } catch (error) {\n      console.warn(\"[MapChannel] Failed to subscribe to points channel:\", error)\n    }\n  } else {\n    console.log(\n      \"[MapChannel] Live mode disabled, not subscribing to PointsChannel\",\n    )\n  }\n\n  // Note: NotificationsChannel is handled by notifications_controller.js in the navbar\n  // Creating a second subscription here causes issues with ActionCable\n\n  // Subscribe to tracks channel for real-time track updates\n  try {\n    subscriptions.tracks = consumer.subscriptions.create(\"TracksChannel\", {\n      connected() {\n        console.log(\"TracksChannel connected\")\n        callbacks.connected?.(\"tracks\")\n      },\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/maps_maplibre/channels/map_channel.js#L73-L109","documentation":"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.","triggerScenarios":"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://.","commonSituations":"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.","solutions":["Filter the Network tab by WS: the /cable connection should be 101 Switching Protocols","Fix the proxy to pass Connection/Upgrade headers and permit long-lived connections for the cable path","Confirm the cable URL uses wss:// when the page is served over https","Reload after backend channel renames and cache-bust stale JS bundles"],"exampleFix":"// before\nsubscriptions.points = consumer.subscriptions.create(\"PointsChannel\", { ...handlers })\n// after\ntry {\n  subscriptions.points = consumer.subscriptions.create(\"PointsChannel\", {\n    rejected() { console.warn(\"[MapChannel] Points channel rejected subscription\") },\n    ...handlers,\n  })\n} catch (error) {\n  console.warn(\"[MapChannel] Failed to subscribe to points channel:\", error)\n}","handlingStrategy":"try-catch","validationCode":"if (!enableLiveMode) return\nif (!consumer || typeof consumer.subscriptions?.create !== \"function\") return","typeGuard":null,"tryCatchPattern":"try {\n  subscriptions.points = consumer.subscriptions.create(\"PointsChannel\", {\n    rejected() { console.warn(\"[MapChannel] Points channel rejected subscription\") },\n    ...handlers,\n  })\n} catch (error) {\n  console.warn(\"[MapChannel] Failed to subscribe to points channel:\", error)\n  // Live points are an enhancement; the map remains fully functional without them\n}","preventionTips":["Confirm the /cable WebSocket upgrade (101) in the Network tab before debugging channel code","Use wss:// cable URLs whenever the page is served over https","Add rejected() handlers so server-side subscription rejections surface instead of failing silently"],"tags":["actioncable","websocket","live-mode","points","realtime"],"backgroundTag":"actioncable-subscription-failed","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}