title: Exception thrown in queued task- Helper returns correct value but throws error- Meteor
body: <p>Fix this Error which is thrown in console on this page: <a href="http://salestrack.meteor.com/demos/overview" rel="nofollow">http://salestrack.meteor.com/demos/overview</a>: </p>
  
  <pre><code>Exception in queued task: TypeError: Cannot read property 'emails' of undefined at         Object.Template.demoOverviewItem.helpers.ownerRep       (http://localhost:3000/client/views/overviews/demo_overview_item.js?
  </code></pre>
  
  <p>Here is the helper they're referring to: </p>
  
  <pre><code>ownerRep: function(){
  var rep = Meteor.users.findOne({_id: this.userId}); 
  var repEmail = rep.emails[0].address, 
  repArr = [], 
  repArr = repEmail.split('@'); 
  return repArr[0]; 
  }
  });
  </code></pre>
  
  <p>The query is inserted into an inclusion block that loops over #each demos and looks up this.userId from the demos collection and matches it up to the user to return the owner of the demo's name. </p>
  
  <p>Here are the templates that: </p>
  
  <pre><code>    &lt;template name="demosOverview"&gt;
      &lt;div class="container-fluid"&gt;
      &lt;div class="row-fluid col-lg-10 col-lg-offset-1"&gt;
  
      &lt;table class="table table-striped table-hover table-bordered dataTable" id="editable-    sample"&gt;
      &lt;thead&gt;
         &lt;tr&gt;
          &lt;th&gt;Rep&lt;/th&gt;
          &lt;th&gt;SFID&lt;/th&gt;
          &lt;th&gt;Date Set&lt;/th&gt;
          &lt;th&gt;Closed&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
       &lt;tbody&gt;
        {{#each demos}}
           {{&gt; demoOverviewItem}}
        {{/each}}
       &lt;/tbody&gt;
  
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  
  &lt;template name="demoOverviewItem"&gt;
   &lt;tr&gt;
      &lt;td&gt;{{ownerRep}}&lt;/td&gt;
      &lt;td&gt; &lt;a href="{{pathFor 'demoPage'}}"&gt;{{sfid}}&lt;/a&gt; 
  
      &lt;a href="{{sfid}}" class="pull-right" target="blank" title="Salesforce"&gt;
      &lt;img src="/img/salesforce-logo.png" height="16" width="16"&gt;
      &lt;/a&gt;
  
      &lt;/td&gt;
      &lt;td&gt;{{dateset}}&lt;/td&gt;
      &lt;td&gt;{{closed}}&lt;/td&gt;
   &lt;/tr&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>I am pub/subbing Meteor.users.find() from the server to the client but haven't paired it down to only send over certain fields yet (for easy hacking purposes). </p>
  
  <p>Weird thing is that it works correctly and returns the demo owner's email address as expected. The error gets thrown when I reload the page but not when I navigate to it from elsewhere on the site. </p>
  
  <p>Seems like a wait.On error or something where when I hit reload it doesn't know that currentUser = true so it throws the error before realizing I'm logged in- that's just a theory though. I've googled, StackOv and IRCed to no avail. </p>