meteor-messageformat icon indicating copy to clipboard operation
meteor-messageformat copied to clipboard

Weird critical bug when opening translate page

Open isAlmogK opened this issue 10 years ago • 6 comments

So I'm getting a really weird bug. If I have my app open in one tab and then open another tab going to the message format translate page. I run into a number of errors and issues. For example I lost data and get Type Error.

This only happens if I open the translate page. Attached screenshots to better explain.

When the translate page is open screen shot 2015-03-20 at 3 42 30 pm

Here is the translate page screen shot 2015-03-20 at 3 42 21 pm

When the translate page is closed (but I have to close and open the tab / app) screen shot 2015-03-20 at 3 44 59 pm

And this is the error I'm getting

Exception in template helper: TypeError: Cannot read property 'userId' of undefined at Object.Template.organization.helpers.ownsOrganization (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:431:96) at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:28387 at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:16297 at Object.l.call (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:123:1819) at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:285:10424 at null. (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:25621) at https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:18019 at Object.l._withCurrentView (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:21048) at a (https://app.goplatfarm.com/027fedd41da9152712098bff68b817bd1181a902.js:60:17977)

isAlmogK avatar Mar 20 '15 13:03 isAlmogK

I don't see anything messageformat specific in the error. Could be a problem with subscriptions and reactivity. Can you show me the code for the Template.organization ownsOrganization helper?

gadicc avatar Mar 20 '15 15:03 gadicc

@gadicc I also thought it was not related to message format but it only happens when I open the translate page.

It's a simple check var noOrganization = _.isEmpty(Meteor.user().organizationId) === true;

I think something happens with the user or allow / deny when the translate page opens

isAlmogK avatar Mar 20 '15 16:03 isAlmogK

That's super weird that the translate page could affect the main meteor user subscription. But if that's your only problem, the fix is quite easy :)

var user = Meteor.user();
var noOrganization = user && _.isEmpty(user.organizationId);

The /translate route doesn't do anything user related, and the allow/deny callbacks are only checked when trying to enter a language.

gadicc avatar Mar 20 '15 16:03 gadicc

Wait I just realized that's the wrong line... it's something needing .userId. Or did you past me the full function and that error is coming from inside of Meteor?

gadicc avatar Mar 20 '15 16:03 gadicc

Yea it's a weird bug, as for the code here is the entire function it's inside iron-router

OrganizationController = RouteController.extend({
  template: 'organization',
  waitOn: function() {
    if(getConnectionStatus()) {
      return Meteor.subscribe('organizations');
    } else {
      this.render();
    }
  },
  organization: function() {
    return Organizations.findOne();
  },
  data: function() {
    var noOrganization = _.isEmpty(Meteor.user().organizationId) === true;
    return {
      organization: this.organization(),
      noOrganization: noOrganization
    };
  },
  onBeforeAction: function () {
    AccountsEntry.signInRequired(this);
  }
});

isAlmogK avatar Mar 20 '15 16:03 isAlmogK

@almogdesign I can't reproduce that in [v2]. Which version are you using?

DSpeichert avatar Jan 16 '16 17:01 DSpeichert