Hardhat.Middleware.Timeout (hardhat v1.1.0)

Abort HTTP requests after the given timeout or the current Deadline, and emit OpenTelemetry trace events on timeouts.

Options:

  • :timeout - (required) timeout in milliseconds

OpenTelemetry

Implementing a timeout necessitates moving the request into a new process, and then waiting on that new process's completion (or aborting after the timeout). Since OpenTelemetry tracing context is stored in the process dictionary, that context must be explicitly propagated to the new process. This middleware uses OpentelemetryProcessPropagator for this purpose.

In the event of a timeout result in this middleware, a new timeout_exceeded event will be added to the trace. The event will include these attributes:

  • module - the client module that includes this middleware
  • timeout - the duration that was exceeded

Deadline

When the caller has set a Deadline for the current process, that limit will be respected by this middleware. The effective timeout chosen will be the lesser of the time remaining on the current deadline and the duration given in the :timeout option.