You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to cancel an ongoing request like this:
constrequest=got(url,{retry: 0})functionstartTimer(r: typeofrequest){returnsetTimeout(()=>r.cancel(),timeoutMs)}consttimer=startTimer(request)constresponse=awaitrequestclearTimeout(timer)// check response or handle error
but I get TypeError: r.cancel is not a function at runtime. Typescript thinks all is OK at compile time and can see that request and r are of type CancelableRequest.
I must be doing something wrong; I'm new to got.
(I'm trying this method because I have a server that may be down and I don't want to wait a long time for ECONNREFUSED -- I tried setting all the timeouts in options.timeout, but they had no effect, so I'm trying this.)
Checklist
I have read the documentation.
The text was updated successfully, but these errors were encountered:
What would you like to discuss?
I'm trying to cancel an ongoing request like this:
but I get
TypeError: r.cancel is not a function
at runtime. Typescript thinks all is OK at compile time and can see thatrequest
andr
are of typeCancelableRequest
.I must be doing something wrong; I'm new to got.
(I'm trying this method because I have a server that may be down and I don't want to wait a long time for ECONNREFUSED -- I tried setting all the timeouts in
options.timeout
, but they had no effect, so I'm trying this.)Checklist
The text was updated successfully, but these errors were encountered: