Exception in template helper at http request

I’m getting the following error more than once when I call an http request to do a web scrape:

Exception in template helper: @http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357 line 365 > eval:2:13
.globalEval/<@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:365:5
.globalEval@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:364:1
.domManip@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:6006:1
.append@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:5779:1
.html/<@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:5905:5
jQuery.access@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:4178:5
.html@http://192.168.28.23:3000/packages/jquery.js?1015953f785c9b76503e2ecb391507dce965f357:5869:1
.getTheInfo@http://192.168.28.23:3000/app/client/home.js?66fbe5ae7e08724fc82af5222f61d0591d8433ee:13:21
bindDataContext/<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:2986:14
Blaze._wrapCatchingExceptions/<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:1650:14
wrapHelper/</<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3038:14
Template._withTemplateInstanceFunc@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3671:12
wrapHelper/<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3037:1
Spacebars.call@http://192.168.28.23:3000/packages/spacebars.js?1aedcc2aa3ae9ff5d860d73516110cedd77c033e:167:12
Spacebars.mustacheImpl@http://192.168.28.23:3000/packages/spacebars.js?1aedcc2aa3ae9ff5d860d73516110cedd77c033e:104:10
Spacebars.mustache@http://192.168.28.23:3000/packages/spacebars.js?1aedcc2aa3ae9ff5d860d73516110cedd77c033e:108:16
Template.home</<@http://192.168.28.23:3000/app/client/template.home.js?94fb4b9d4c368047db0aefdf11f35cda26c0dcb4:6:12
doRender@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:2024:20
viewAutorun/</<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:1872:18
Template._withTemplateInstanceFunc@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:3671:12
viewAutorun/<@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:1870:1
Blaze._withCurrentView@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:2211:12
viewAutorun@http://192.168.28.23:3000/packages/blaze.js?9391df93ba5076c2cfc61ee68724eb79b65f00d9:1869:1
Tracker.Computation.prototype._compute@http://192.168.28.23:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:349:5
Tracker.Computation.prototype._recompute@http://192.168.28.23:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:368:9
Tracker._runFlush@http://192.168.28.23:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:507:9
onGlobalMessage@http://192.168.28.23:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:365:11

on closer inspection I find the name of the client side method that the helper calls: getTheInfo
Template.home.helpers({ 'getTheInfo': function(){ getInfoClient(); var info = Session.get('info'); var stuff = $('#main-container').html(info.content); return stuff; } }); getInfoClient = function(){ Meteor.call('getInfoXML', function(error, result){ if (error){ console.log("custom error " + error);} else { Session.set('info', result); } }); }

My problem is what could possibly be throwing the error(s). I get the info that I want scraped, and I ultimately get the desired result. However, this is concerning me. Could anyone pick out what I might have missed?

I’m not sure if this is the error you’re seeing or not, but in your code you’re making your method call via the getInfoClient() function, then immediately pulling info out of the session, and accessing it via info.content. The thing is you’re storing the result of your method call into the session via a function called asynchronously, which means when you access info.content there’s a good chance info is actually undefined, since Session.get('info') will return undefined. You might want to add some additional checks to make sure you aren’t trying to use info until it contains a valid value.