title: Express js res.redirect() from mongoose callback not working
body: <p>What I'm trying to do here is,</p>
  
  <p>from <code>/expense/new</code> page submitting <code>POST</code> request to <code>/expense/newPost</code></p>
  
  <p>on Expressjs, handling this way</p>
  
  <pre><code>app.post('/expense/newPost', function(req, res) { ...
  </code></pre>
  
  <p>continue, using <code>mongoose</code> I validate the collection as </p>
  
  <pre><code>tmpExp = new Expense(req.body);
  
  tmpExp.validate(function(err) {
    if(err || !isValidForm) {
      req.session.form.errField =  _.extend(req.session.form.errField, (err.errors || err ));
      req.session.rePop = req.body;
      res.redirect('/expense/new');
    } else {
      console.log('now saving') // successfully logs here.
      tmpExp.save(expPost, function(err2, savedDoc) {
        if(err2) {
          req.session.flash = { 
              global: true
            , css: "error"
            , message: "Internal Server Error"
          }
          res.redirect('/expense/new');
        } else {
          res.redirect('/expense/new?success=' + savedDoc.bill_id);
        }
      });
    }
  });
  </code></pre>
  
  <p>for shake of clearity I removed some of the validation code.</p>
  
  <p><strong>Now the problem is, after submitting the POST request by browser data is successfully saved in mongodb but browser not redirect and just waiting for response from server</strong></p>