diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index 3e195a81..9f74143f 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -98,19 +98,15 @@ private[dom] object FetchClient { mergedOptions.referrerPolicy.foreach(init.referrerPolicy = _) val fetch = - poll(F.fromPromise(F.delay(Fetch.fetch(req.uri.renderString, init)))) + F.fromPromise(F.delay(Fetch.fetch(req.uri.renderString, init))) .onCancel(F.delay(abortController.abort())) - - requestTimeout match { - case d: FiniteDuration => - fetch.timeoutTo( - d, + .timeoutTo( + requestTimeout, F.raiseError[FetchResponse](new TimeoutException( - s"Request to ${req.uri.renderString} timed out after ${d.toMillis} ms")) + s"Request to ${req.uri.renderString} timed out after ${requestTimeout.toMillis} ms")) ) - case _ => - fetch - } + + poll(fetch) } } { case (r, exitCase) =>