title: Should I use await inside Promise.all?
body: <p>I'm building express middleware to make two async calls to the database to check if the username or email are already in use. The functions return promises without a catch, as I want to keep database logic seperate from req/res/next logic, and I have centralised error handling that requires <code>next</code> as an argument. In my postman testing on local environment the following code works as expected and my centralised errorhandler returns the error to the client:</p>
  <pre><code>async checkUsernameExists(username) {
      await this.sequelize.transaction(
        async () =&gt;
          await this.User.findOne({
            where: {
              username,
            },
          }).then(user =&gt; {
            if (user) throw new Conflict('Failed. Username already in use.');
          }),
      );
    }  
  
  const checkDuplicateUsernameOrEmail = async (
    { body: { email, username } },
    res,
    next,
  ) =&gt; {
  
    await Promise.all([
      checkUsernameExists(username),
      checkEmailExists(email),
    ])
      .then(() =&gt; next())
      .catch(error =&gt; next(error));
  };
  </code></pre>
  <p>However, as the <code>checkExists</code> functions are async, shouldn't they be included in <code>Promise.all</code> with await? Or does <code>Promise.all</code> do this automatically?</p>
  <pre><code>await Promise.all([
      await checkUsernameExists(username),
      await checkEmailExists(email),
    ])...
  </code></pre>
  <p>This leads to an unhandled promise rejection from checkUsernameExists  and no response is sent back to the client.</p>