Creates a middleware bounding the wait for a response.
Decorates a Fetch implementation with one giving up on an exchange whose response doesn't arrive within
limit milliseconds, reporting a 504 Gateway Timeout in its place, so that a server that never replies is handled
as any other unsuccessful exchange and status handling stays with the consumer.
The bound covers the wait for the response only: it is lifted as soon as the response is reported, leaving the body
free to be streamed for as long as it takes, so that a large resource is not truncated while a slow server is given
up on.
The status is reported as soon as the bound expires, whether or not the transport gives up on the exchange, so that
the wait is bounded even by an implementation ignoring the abort: a response or a failure reported after that point
is discarded, rather than relayed or reported as a timeout.
An exchange stating a signal of its own is aborted by that signal or by the bound, whichever fires first, and an
abort asked for from the outside before the bound expires is relayed to the caller as it was reported, rather than
reported as a timeout. A signal supplied through init supersedes the one carried by a
Request input, as it does in the Request constructor:
a signal reported as undefined counts as unstated, while an explicit null clears it, leaving the bound as the
only signal.
A Request input reaches the transport as it was submitted, but for the signal: its body is relayed undisturbed and
its referrer and referrer policy are preserved.
Note
504 is one of the transient statuses throttle retries: declaring this middleware
after it bounds each attempt on its own, while declaring it before bounds the retry sequence as a whole.
Parameters
limit: number
The maximum number of milliseconds to wait for a response
Creates a middleware bounding the wait for a response.
Decorates a Fetch implementation with one giving up on an exchange whose response doesn't arrive within
limitmilliseconds, reporting a504 Gateway Timeoutin its place, so that a server that never replies is handled as any other unsuccessful exchange and status handling stays with the consumer.The bound covers the wait for the response only: it is lifted as soon as the response is reported, leaving the body free to be streamed for as long as it takes, so that a large resource is not truncated while a slow server is given up on.
The status is reported as soon as the bound expires, whether or not the transport gives up on the exchange, so that the wait is bounded even by an implementation ignoring the abort: a response or a failure reported after that point is discarded, rather than relayed or reported as a timeout.
An exchange stating a signal of its own is aborted by that signal or by the bound, whichever fires first, and an abort asked for from the outside before the bound expires is relayed to the caller as it was reported, rather than reported as a timeout. A signal supplied through
initsupersedes the one carried by aRequestinput, as it does in theRequestconstructor: a signal reported asundefinedcounts as unstated, while an explicitnullclears it, leaving the bound as the only signal.A
Requestinput reaches the transport as it was submitted, but for the signal: its body is relayed undisturbed and its referrer and referrer policy are preserved.504is one of the transient statuses throttle retries: declaring this middleware after it bounds each attempt on its own, while declaring it before bounds the retry sequence as a whole.