Reputation: 343
As described above, I am getting an error and an empty page (but the layout including the navbar is there) is shown. This error always occurs, when I refresh the link via the browser or in case I access the link directly through the browser. Everything is fine, when I use my navigation bar to navigate through the templates. So, I can´t see any data after a real "load" of the page.
I am using Meteor Blaze on Windows.
Neither the picture, nor other data is shown.
I am not sure, if this is 100% the reason for that behavior, but always if this behavior occurs, I get this error message in the client console:
Exception from Tracker afterFlush function: undefined
and
TypeError: Cannot read property 'username' of undefined at Blaze.TemplateInstance. (http://localhost:3000/app/client/templates/common/navigation.js?hash=142e989d312ba94a4b875a71e5e557bdd5255272:3:40) at http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3398:22 at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3744:12) at fireCallbacks (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3394:12) at Blaze.View. (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3487:5) at http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1845:14 at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:2271:12) at http://localhost:3000/packages/blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1844:15 at Object.Tracker._runFlush (http://localhost:3000/packages/tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:548:11) at onGlobalMessage (http://localhost:3000/packages/meteor.js?hash=6d285d84547b3dad9717a7c89c664b61b45ea3d8:398:23) undefined
I searched for tracker, afterFlush etc., but I am not sure what I have to change in my code?
Upvotes: 1
Views: 704
Reputation: 20226
When you load this route "fresh" (using a refresh or pasting the url into the browser) Meteor reloads the entire application including the Meteor.user()
object. At line 40 of client/templates/common/navigation.js
you are probably trying to access Meteor.user().username
but Meteor.user()
hasn't yet loaded so you get the error. You need to defend against this in your code and/or show a loading template until your subscriptions and the user object are all ready.
The first line of the error dump points to the error:
TypeError: Cannot read property 'username' of undefined at Blaze.TemplateInstance.
(http://localhost:3000/app/client/templates/common/navigation.js?hash=142e989d312ba94a4b875a71e5e557bdd5255272:3:40)
The :40
at the end there is the line number the error occurred on.
Upvotes: 2