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
{{ message }}
Repository navigation
AbortController.abort is missing parameter support #47505
It would be quite handy to have this in place because it would be possible to set a timeout to api calls (just one example) and then get a custom error object thrown in case the request takes too long.
The Error Parameter bellow controller.abort(new Error("This call takes too long")); would not work with the current implementation. Instead its only possible to abort like controller.abort() and then get a "standard" abort error thrown.
Thanks Johann Pinson (@johannpinson) -- although I'm on that version of typescript, in my project the type inference is coming from @types/node which doesn't yet have the reason parameter.
Edit:
In the meantime, I think I can get around it via:
import'node';/** * Workaround due to outdated typings. * https://github.com/microsoft/TypeScript/issues/47505 */declare global {interfaceAbortController{/** * Returns the AbortSignal object associated with this object. */readonlysignal: AbortSignal;/** * Invoking this method will set this object's AbortSignal's aborted flag * and signal to any observers that the associated activity is to be aborted. */abort(reason?: any): void;}interfaceAbortSignal{/** * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */readonlyaborted: boolean;/** * Returns the reason, if any, when this AbortSignal's AbortController signaled to abort. */readonlyreason?: any;}}
Although typescript v4.6.4 updated the AbortController.abort method to accept a reason parameter, the AbortSignal interface was not updated to expose the reason property =/
Activity
johannpinson commentedon May 11, 2022
Hello laurenzhonauer
For your information, it looks to be fixed with the
4.6release (feb 2022).The latest
v4.6.4has thereasonparameterhttps://github.com/microsoft/TypeScript/blob/v4.6.4/lib/lib.dom.d.ts#L1895-L1906
douglascayers commentedon May 11, 2022
Thanks Johann Pinson (@johannpinson) -- although I'm on that version of typescript, in my project the type inference is coming from @types/node which doesn't yet have the
reasonparameter.Edit:
In the meantime, I think I can get around it via:
douglascayers commentedon May 12, 2022
Although typescript v4.6.4 updated the AbortController.abort method to accept a
reasonparameter, the AbortSignal interface was not updated to expose thereasonproperty =/https://github.com/microsoft/TypeScript/blob/v4.6.4/lib/lib.dom.d.ts#L1913-L1921
tonivj5 commentedon Mar 3, 2023
I think this issue is resolved, isn't it?
RyanCavanaugh commentedon Mar 3, 2023
Seems so. Thanks!
eden-eitani commentedon Apr 16, 2023
Doug Ayers (@douglascayers) did you find another solution?