title: Using asynchronous methods but Express still returning 503 (NodeJS)
body: <p>I'm developing a web application in NodeJS with an Express back-end. The application is running smoothly except that when a user signs up, a somewhat long operation is called on the back end that involves saving to a database, resizing an image, etc. It takes a few seconds for this process to complete, and during this time anyone else who makes a request to the server will receive a 503 error and will be unable to do anything, whether that's sending or receiving data. I am using asynchronous functions in order to do this whole process. I am using multer to read the file, fs to read and write the file, and Jimp to resize the image. The code is as shown below.</p>
  
  <pre><code>module.exports = function(router) {
  router.route('/')
      .post(function(req, res, next) {
          upload(req, res, function(err) {
              var salt = bcrypt.genSaltSync(saltRounds);
              var identifier = makeIdentifier(req.body.first_name.trim())
              let emailNotifications = 0;
              if (req.body.email_notifications === 'true') {
                  emailNotifications = 1;
              }
              var signup = {
                  identifier: identifier,
                  first_name: toTitleCase(req.body.first_name.trim()),
                  last_name: req.body.last_name.trim(),
                  hobby: req.body.hobby,
                  type: 'user',
                  email: req.body.email.trim(),
                  email_notifications: emailNotifications,
                  password: bcrypt.hashSync(req.body.password, salt)
              };
  
              let ascii = /^[ -~]+$/;
  
              for (var propertyName in signup) {
                  if (!ascii.test(signup[propertyName])) {
                      res.json({
                          reason: "invalid-characters"
                      });
                      return;
                  }
              }
              if (req.file.size &gt; 5000000) {
                  res.json({
                      reason: "file-size"
                  });
                  return;
              }
              let emailExists = false;
              db.doesEmailExist(req.body.email, function(err, results) {
                  if (err) {
                      res.status(500).send("Server error");
                      return;
                  } else {
                      if (results.length &gt; 0) {
                          res.json({
                              reason: "email-exists"
                          });
                          return;
                      } else {
                          fs.readFile(req.file.path, function(err, data) {
                              let newPath = __dirname + "/profile-pictures/" + identifier + ".png";
                              fs.writeFile(newPath, data, function(err) {
                                  if (err) {
                                      console.log(err);
                                  } else {
                                      try {
                                          Jimp.read(newPath, (err, file) =&gt; {
                                              if (err) throw err;
                                              file
                                                  .resize(300, 300) // resize
                                                  .quality(60) // set JPEG quality
                                                  .write(newPath); // save
                                          });
                                      } catch (error) {
                                          res.json({
                                              reason: "image-properties"
                                          });
                                          return
                                      }
                                  }
                              });
                          });
                          db.signup(signup, function(err, results) {
                              if (err) {
                                  res.status(500).send("Server error");
                                  return;
                              } else {
                                  res.json({
                                      success: true
                                  });
                                  return;
                              }
                          })
                      }
                  }
              })
          })
      });
  }
  </code></pre>
  
  <p>What is causing the server to respond with a 503 error? Any help would be appreciated, thanks!</p>