meteor-mantra-kickstarter icon indicating copy to clipboard operation
meteor-mantra-kickstarter copied to clipboard

logout and tracker errors

Open solace opened this issue 8 years ago • 3 comments

Hi,

This isn't exactly related to what is currently in the repo, but as authentication and profile/accounts pages are partially implemented and stubbed out, this seems like it'll be relevant later.

I've been building out the profile page, but when a logout is triggered, just before the re-route, it raises Tracker recompute errors when the user data is suddenly missing.

Is there a graceful way of handling this, or is the only way to just null test the user record whereever it is used?

Thanks

solace avatar Feb 22 '16 08:02 solace

Can you please provide some more details, error log?

makstr avatar Feb 23 '16 01:02 makstr

The composers/account/profile.jsx which I'm using to create a form the user can use to update their profile, uses this, which I modified from auth.jsx:

    if (Meteor.subscribe('users.current').ready()) {
        const record = Meteor.users.findOne(Meteor.userId());
        onData(null, {record, error, success});
    }

If for example in the corresponding _form.jsx, you have:

    render() {
        const {record, error, success} = this.props;
        return (
            <div>
                {record.profile.firstName}
            </div>
        );
    }

Navigating to /profile will display the logged in user's first name.

If you click Logout in the menu, in the console you will see:

Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property 'profile' of undefined
    at render (_form.jsx:##)

Right before the logout action redirects to the public page.

solace avatar Feb 23 '16 02:02 solace

I constantly run into this error, and as you suggest, usually just null test the meteor.id() before doing something that might result in an error. There must be a better way... @solace, do you remember what you did?

charlesdeb avatar Sep 19 '17 01:09 charlesdeb