Skip to main content



  • rejectIfTimeout(timeout: number, error: Error): [Timer, Promise<never>]

  • Enforce a timeout on a promise, so that it can be rejected if it takes too long to complete

    const [timerId, promise] = web3.utils.rejectIfTimeout(100, new Error('time out'));


    • timeout: number

      The timeout to enforced in milliseconds.

    • error: Error

      The error to throw if the timeout is reached.

    Returns [Timer, Promise<never>]

    A tuple of the timeout id and the promise that will be rejected if the timeout is reached.