kadirahq/subs-manager

error invoking SubsManager.subscribe: undefined

markshust opened this issue · 1 comments

I receive this error when listening to subscribe within react-komposer onChange, for example:

const onChange = ({ areaId, sectionId }, onData) => {
  subs.subscribe('area.list');
  subs.subscribe('company.detail');
  subs.subscribe('item_to_section.list');
  subs.subscribe('section.list');

  if (subs.ready()) {
  ...

It appears this happens because these are all authenticated routes, and on initial load, user is not yet authenticated. Since I'm handling auth logic through Tracker Autorun, the container component is attempting to load these subscriptions, but they are returning undefined, causing an error in the browser console:

screen shot 2016-05-20 at 12 38 53 pm

Is there any way to prevent this error from being logged? This happens not only for anonymous users, but also when a user logs out.

Looking at the code, it appears its just a console log, and not an actual error going on. Perhaps it would just be best to eliminate the console.log, as it's not really needed?

  function errorHandlingLogic (err) {
    console.log("Error invoking SubsManager.subscribe(%s): ", sub.identifier , err.reason);
    // expire this sub right away.
    // Then expiration machanism will take care of the sub removal
    sub.updated = new Date(1);
  }