title: Apostrophe CMS - afterInsert is called multiple times
body: <p>In Apostrophe CMS I have a piece that I wish to be submitable using <code>apostrophe-submit-widgets</code> - and everything seems to be working, except that my afterInsert method is called twice and thus sends twice the amount of emails.</p>
  
  <p>My configuration looks like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>const nodemailer = require('nodemailer')
  const colors = require('colors')
  
  module.exports = {
    extend: 'apostrophe-pieces',
    name: 'request-form',
    label: 'Request Form',
    alias: 'requestForm',
    //...
    ],
    construct: function (self, options) {
      self.beforeSave = function (req, piece, options, callback) {
        piece.title = piece.name + ' ' + piece.email
        piece.published = true
        return callback()
      }
      self.afterInsert = async function (req, piece, options, callback) {
        const transporter = nodemailer.createTransport({
          //transport config
        });
  
        function handleError(err) {
          console.error(err.cyan)
          return callback(err)
        }
  
        const messageToAdmin = {
          //nodemailer message config
        }
  
  
        const messageToUser = {
          //nodemailer message config
        }
  
        await transporter.sendMail(messageToAdmin)
          .then(transporter.sendMail(messageToUser))
          .catch(handleError)
  
        return callback()
      }
    }
  }
  </code></pre>
  
  <p>Do you have any idea why it might be working like that? The only thing that I was able to find out with debug tools is that the afterInsert is indeed called twice, it's not something inside it that's looped.
  It happens both when I use <code>request-forms-submit-widgets</code> and when I add it from the admin bar.</p>
  
  <p>Edit: As per suggestion I removed <code>then</code> chaining and used instead this:</p>
  
  <pre class="lang-js prettyprint-override"><code>try {
    await transporter.sendMail(messageToAdmin)
    await transporter.sendMail(messageToUser)
    callback()
  } catch (err) {
    console.error(err)
    callback(err)
  }
  </code></pre>
  
  <p>Unfortunately, it did not help.</p>