Freika/dawarich · warning
[MapChannel] ActionCable consumer not available
Error message
[MapChannel] ActionCable consumer not available
What it means
Before creating any channel subscription, this module defensively checks that an ActionCable consumer object was passed in. A null/undefined consumer means the cable setup code (importing @rails/actioncable and calling createConsumer) never ran or returned nothing; the function returns an empty subscription set, so family locations, live points, and track updates are all disabled for the session.
Source
Thrown at app/javascript/maps_maplibre/channels/map_channel.js:24
* @param {Object} options - { received, connected, disconnected, enableLiveMode }
* @returns {Object} Subscriptions object with multiple channels
*/
export function createMapChannel(options = {}) {
const { enableLiveMode = false, ...callbacks } = options
const subscriptions = {
family: null,
points: null,
tracks: null,
}
console.log(
"[MapChannel] Creating channels with enableLiveMode:",
enableLiveMode,
)
// Defensive check - consumer might not be available
if (!consumer) {
console.warn("[MapChannel] ActionCable consumer not available")
return {
subscriptions,
unsubscribeAll() {},
}
}
// Subscribe to family locations if family feature is enabled
try {
const familyFeaturesElement = document.querySelector(
"[data-family-members-features-value]",
)
const features = familyFeaturesElement
? JSON.parse(familyFeaturesElement.dataset.familyMembersFeaturesValue)
: {}
if (features.family) {
subscriptions.family = consumer.subscriptions.create(
"FamilyLocationsChannel",View on GitHub (pinned to 97fad417c5)
Solutions
- Trace where the consumer argument originates — it must come from createConsumer() in @rails/actioncable; confirm that import resolves in the bundle
- Check the browser console for a failed import of @rails/actioncable before this warning
- In tests, inject a minimal fake consumer ({ subscriptions: { create: () => ({ unsubscribe() {} }) } }) or assert the no-subscription path
- Ensure the consumer module is imported and executed before map channels are set up
Example fix
// before
// consumer may be undefined if bootstrap failed
setupMapChannels(consumer, callbacks, enableLiveMode)
// after
import { createConsumer } from "@rails/actioncable"
let consumer = null
try {
consumer = createConsumer()
} catch (e) {
console.warn("[MapChannel] Could not create ActionCable consumer", e)
}
setupMapChannels(consumer, callbacks, enableLiveMode) Defensive patterns
Strategy: validation
Validate before calling
if (!consumer || typeof consumer.subscriptions?.create !== "function") {
// Skip realtime entirely — the map still works without live updates
return { subscriptions, unsubscribeAll() {} }
} Type guard
/** @param {unknown} c @returns {boolean} */
function isActionCableConsumer(c) {
return Boolean(
c &&
typeof c === "object" &&
c.subscriptions &&
typeof c.subscriptions.create === "function"
)
} Prevention
- Create the consumer once in a dedicated bootstrap module and export it so callers cannot receive undefined
- Fail loudly (console.error) in development when realtime is requested without a consumer
- Hide live-mode UI toggles when the consumer is missing so users are not misled
When it happens
Trigger: createConsumer() moved or renamed in the import chain so undefined is passed into setupMapChannels; the cable bootstrap module failing to load (bundler/tree-shaking issue); an exception during module init swallowing consumer creation; running in an environment where ActionCable is intentionally absent (tests, static previews).
Common situations: Refactors of the channels bootstrap module changing its export shape; test harnesses rendering the map without ActionCable; bundler misconfiguration dropping @rails/actioncable from the chunk that calls this module.
Related errors
- [MapChannel] Failed to subscribe to family channel:
- [MapChannel] Failed to subscribe to tracks channel:
- [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/818adecbd5cfc976.
Report an issue: GitHub.