Set Timeout in Google Apps Scripts

Apparently you can use the function Utilities.sleep() like this:

function onSubmit() {
  // we've been called, remove trigger, set timeout, re-enable, and then run function
  destroySubmitHandler();
  Utilities.sleep(5 * 1000)
  createSubmitHandler();
  myFunction()
}

you should try the specially designed function which is to resolve the problem of too much parallel submission:

function onSubmit(e) {
  var lock = LockService.getScriptLock();
  lock.waitLock(30000); // lock 30 seconds

  //do whatever you want here

  lock.releaseLock();
}

It is said the id would be the same without this lock with reference to google dev-document: https://developers.google.com/apps-script/reference/lock/lock

for example, the following is an apps script standalone web-site function:

google.script.run.withSuccessHandler(ready).logNow(email);

I lock it each time the google sheet updating the sheet in case there are multiple guys update it in the same time, or otherwise, the data might overwrite each other:

  var ls = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("logged");
  lock.waitLock(30000);
  ls.getRange(ls.getLastRow()+1, 1).setValue(email);
  lock.releaseLock();

although the 30 seconds seems a lot, once the setValue() function is down, the lock would be released. If you can read Chinese, I recommend this article: https://www.wfublog.com/2017/03/google-apps-script-spreadsheet-delay-write-data.html