title: Callback not called Node.Js for a router application
body: <p>My current code is</p>
  
  <pre><code>resizer.resize(filepath, parsedUrl, fullDestinationPath, function() {
          return self.send(response, 200, {'Content-Type': mime.lookup(fullDestinationPath)}, fs.createReadStream(fullDestinationPath));
      });
  </code></pre>
  
  <p>The resize runs to</p>
  
  <pre><code>Resizer.prototype.resize = function (filepath, parsedUrl, fullDestinationPath) {
           this.read(filepath, parsedUrl, fullDestinationPath);
  };
  </code></pre>
  
  <p>Which then calls </p>
  
  <pre><code>Resizer.prototype.read = function(filepath, parsedUrl, fullDestinationPath){ 
      something.then(function (somethingElse) {
        // Not relevant for question
     }).catch(function (err) {
         console.error(err);
     });
  };
  </code></pre>
  
  <p>I've had a <code>console.log(1);</code> after <code>this.read</code> in the second code snippet to guarantee that it was completely running through it. But returning to my first snippet it doesn't call my callback. The reason I'm using a callback there is because if I don't the send will be executed before a file is completely saved unless it's a very small file, so <code>self.send</code> needs to be called AFTER <code>.resize</code> which is why I am attempting to use a callback.</p>
  
  <p>I've tried multiple things thinking a syntax error might have be the issue or that it was hanging on something, but I've verified it isn't and it is simply not calling the callback. Did I make some kind of obvious mistake? How do I make it call the callback?</p>
  
  <p>I have read questions/answers like this one <a href="https://stackoverflow.com/questions/5010288/how-to-make-a-function-wait-until-a-callback-has-been-called-using-node-js">How to make a function wait until a callback has been called using node.js</a> and understand how it works and implemented it in the same manner, but it's not working for me and I do not see why. Thanks for taking the time to read through this.</p>
  
  <p>EDIT: After fixing the issue with Roberts answer I've removed the callback and changed the code to this, I am using promises instead of callbacks tho:
  Snippet 1:</p>
  
  <pre><code>resizer
          .resize(filepath, parsedUrl, fullDestinationPath)
          .then(function() {
              return self.send(response, 200, {'Content-Type': mime.lookup(fullDestinationPath)}, fs.createReadStream(fullDestinationPath));
          });
  </code></pre>
  
  <p>Snippet 2:</p>
  
  <pre><code>Resizer.prototype.resize = function (filepath, parsedUrl, fullDestinationPath) {
     return this.read(filepath, parsedUrl, fullDestinationPath);
  };
  </code></pre>
  
  <p>Snippet 3:</p>
  
  <pre><code>Resizer.prototype.read = function(filepath, parsedUrl, fullDestinationPath){
      return Jimp.read(filepath)
          .then(function() {
              return //tons of irrelevant code
           })
          .catch(function (err) {
              console.error(err);
          });
  };
  </code></pre>