title: How do I modify spark.js? I'm getting the following error: Exception from Deps recompute: TypeError: Cannot read property 'nodeName' of null
body: <p>UPDATE: The problem is NOT in spark - Although I misunderstood what was going on, and thus the question is somewhat poorly formed, I am leaving this question up just in case it benefits others. </p>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>Exception from Deps recompute: TypeError: Cannot read property 'nodeName' of null
  at Patcher.match (http://localhost:3000/packages/spark.js?3a050592ceb34d6c585c70f1df11e353610be0ab:1540:12)
  </code></pre>
  
  <p>When I click on the link at the second line, it directs me to the following section of spark.js where the error is:</p>
  
  <pre><code>// Look at tags of parents until we hit parent of last-kept,                                   // 229
  // which we know is ok.                                                                        // 230
  for(var a=tgt.parentNode, b=src.parentNode;                                                    // 231
      a !== (starting ? this.tgtParent : lastKeptTgt.parentNode);                                // 232
      a = a.parentNode, b = b.parentNode) {                                                      // 233
    if (b === (starting ? this.srcParent : lastKeptSrc.parentNode))                              // 234
      return false; // src is shallower, b hit top first                                         // 235
    if (a.nodeName !== b.nodeName)                                                               // 236
      return false; // tag names don't match                                                     // 237
  }          
  </code></pre>
  
  <p>The offending line is this one: <code>if (a.nodeName !== b.nodeName)</code>. I want to debug this... how do I modify the spark.js file? I would like to put in statements just as <code>console.log(a)</code>, and would like to check whether <code>a</code> or <code>b</code> has the property <code>nodeName</code>. </p>
  
  <p>Questions on StackOverflow that are relevant to this one are:</p>
  
  <p><a href="https://stackoverflow.com/questions/18283607/how-to-investigate-exception-form-deps-recompute-what-are-the-clues">How to investigate &quot;Exception form Deps recompute&quot; what are the clues?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18448965/how-can-i-modify-the-meteor-meteorite-that-is-running">How can I modify the Meteor (meteorite) that is running?</a></p>
  
  <p>The first one wasn't really answered. The second one included advice on how to add a package to meteor so that you can modify it. But that didn't work for me - my modifications either didn't show up (if I followed the advice in link #2 above) or generated an error saying that meteor could not find spark.js (if I tried to modify the spark.js file in the client folder of  a packages folder in either ~/.meteor/ or the .meteor/ directory of my project.</p>
  
  <p>Would anyone have any advice on how I can modify the spark.js file (the client version) for my meteor project?</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE 09-Nov-2013:</p>
  
  <p>The reason I get these errors is because I am trying to store the results of an asynchronous call to the google maps geocoder.geocode() object/method in a reactive session variable:</p>
  
  <pre><code>SessionAmplify = _.extend({}, Session, {
          keys: _.object(_.map(amplify.store(), function(value, key) {
          return [key, JSON.stringify(value)]
      })),
      set: function (key, value) {
          Session.set.apply(this, arguments);
          amplify.store(key, value);
      },
  });
  
  setLocation = function (e) {
      e.preventDefault;
      var address = e.target.value;
      geocoder = new google.maps.Geocoder();
      geocoder.geocode( { 'address': address}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {      
              map.setCenter(results[0].geometry.location);
              $('.found-address').html(results[0].formatted_address);
  
              SessionAmplify.set('pos', results[0].geometry.location);
              SessionAmplify.set('formatted_address', results[0].formatted_address);
  
          } else {
              alert('Geocode was not successful for the following reason: ' + status);
          }
      });
      return true;
  };
  </code></pre>
  
  <p>The problem lines are <code>SessionAmplify.set('pos', results[0].geometry.location);</code> and <code>SessionAmplify.set('formatted_address', results[0].formatted_address);</code>. It seems that the <code>results</code> variable does not arrive in time for me to set the session variable - this is strange because that block of code should not run unless the <code>status</code> variable arrives, which I would think should arrive concurrently with the <code>results</code> variable.</p>
  
  <p>I looked into using <code>Meteor._wrapAsync()</code> (I watched the eventedmind tutorial: <a href="https://www.eventedmind.com/feed/Ww3rQrHJo8FLgK7FF" rel="nofollow noreferrer">https://www.eventedmind.com/feed/Ww3rQrHJo8FLgK7FF</a>), but I can't figure out how to use <code>Meteor._wrapAsync()</code> with <code>geocoder.geocode()</code>. One problem is that <code>Meteor._wrapAsync()</code> requires the callback function to have the form function(error, result), but the geocode call back's function has the form <code>function(result, status)</code>. Any advice anyone?</p>