{"record":{"id":"7776278503a5a9c5","repo":"Freika/dawarich","slug":"mapchannel-failed-to-subscribe-to-tracks-channel","errorCode":null,"errorMessage":"[MapChannel] Failed to subscribe to tracks channel:","messagePattern":"\\[MapChannel\\] Failed to subscribe to tracks channel:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/maps_maplibre/channels/map_channel.js","lineNumber":126,"sourceCode":"      },\n\n      disconnected() {\n        console.log(\"TracksChannel disconnected\")\n        callbacks.disconnected?.(\"tracks\")\n      },\n\n      received(data) {\n        console.log(\"TracksChannel received:\", data)\n        callbacks.received?.({\n          type: \"track_update\",\n          action: data.action,\n          track: data.track,\n          track_id: data.track_id,\n        })\n      },\n    })\n  } catch (error) {\n    console.warn(\"[MapChannel] Failed to subscribe to tracks channel:\", error)\n  }\n\n  return {\n    subscriptions,\n    unsubscribeAll() {\n      Object.values(subscriptions).forEach((sub) => {\n        sub?.unsubscribe()\n      })\n    },\n  }\n}\n","sourceCodeStart":108,"sourceCodeEnd":138,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/maps_maplibre/channels/map_channel.js#L108-L138","documentation":"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.","triggerScenarios":"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.","commonSituations":"WebSocket-incompatible proxies in front of self-hosted instances; backend upgrades renaming TracksChannel; authorization changes rejecting subscription creation; stale cached assets after deploy.","solutions":["Verify the /cable WebSocket connects (101 status) in the Network tab","Align the channel identifier string with the Rails channel class name after upgrades","Ensure proxy WebSocket upgrade configuration covers the cable mount path","Cache-bust the JS bundle after backend channel changes"],"exampleFix":"// before\nsubscriptions.tracks = consumer.subscriptions.create(\"TracksChannel\", { ...handlers })\n// after\ntry {\n  subscriptions.tracks = consumer.subscriptions.create(\"TracksChannel\", {\n    rejected() { console.warn(\"[MapChannel] Tracks channel rejected subscription\") },\n    ...handlers,\n  })\n} catch (error) {\n  console.warn(\"[MapChannel] Failed to subscribe to tracks channel:\", error)\n}","handlingStrategy":"try-catch","validationCode":"if (!consumer || typeof consumer.subscriptions?.create !== \"function\") return","typeGuard":null,"tryCatchPattern":"try {\n  subscriptions.tracks = consumer.subscriptions.create(\"TracksChannel\", {\n    rejected() { console.warn(\"[MapChannel] Tracks channel rejected subscription\") },\n    ...handlers,\n  })\n} catch (error) {\n  console.warn(\"[MapChannel] Failed to subscribe to tracks channel:\", error)\n  // Track updates simply stop being live; manual refresh still works\n}","preventionTips":["Keep channel identifier strings in one constants module shared with backend naming after upgrades","Test the cable path behind the same proxy configuration as production","Cache-bust frontend bundles after backend channel renames"],"tags":["actioncable","websocket","tracks","realtime","dawarich"],"backgroundTag":"actioncable-subscription-failed","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}