code: async function createPromiseWithTimeout(promise, timeout, desc) {
    if (!(promise instanceof Promise))
      throw new Error('Promise expected')
    if (!timeout)
      throw new Error('Timeout must be a number')
    if (timeout < 0)
      throw new Error('Timeout cannot be negative')
  
    const { promise: toPromise, timeout: to } = makeTimeoutPromise(desc, timeout)
    try {
      return await Promise.race([
        promise,
        toPromise,
      ])
    } finally {
      clearTimeout(to)
    }
  }
docs: Create a promise which will be rejected after a timeout.
  @param {!Promise} promise A promise to race with
  @param {number} timeout Timeout in ms after which to reject
  @param {string} [desc] Description of a promise to be printed in error
  @returns {!Promise} A promise with a timeout