-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage of AbortController ist breaking for setup without DOM Library #4124
Comments
I guess importing typings from |
In the past, whenever Axios has accidentally started to rely on DOM-only types, the preferred fix was to revert such types back to
Good point. However, Node 15 is an "experimental" branch and Node 16 LTS still has a month left before becoming the "active" development line. My suggestion would be to fix the current issue by setting the type to |
…ntroduced in version 0.22.0
I don't think it's really necessary to define a more generic type
|
This just created a fairly gnarly build issue via another library (NestJS) which uses Axios, so I'd like to second the "setting the type to any" solution, if only to minimise the number of engineers who need to trace this down. |
You're right, that's the consequence of using An alternative would be for Axios to provide its own copy of /** A controller object that allows you to abort one or more DOM requests as and when desired. */
interface AbortController {
/**
* Returns the AbortSignal object associated with this object.
*/
readonly signal: 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(): void;
}
declare var AbortController: {
prototype: AbortController;
new(): AbortController;
};
interface AbortSignalEventMap {
"abort": Event;
}
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
interface AbortSignal extends EventTarget {
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*/
readonly aborted: boolean;
onabort: ((this: AbortSignal, ev: Event) => any) | null;
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
declare var AbortSignal: {
prototype: AbortSignal;
new(): AbortSignal;
}; However, please note that when I proposed a similar solution for
I believe Axios should work for both front-end and back-end without resorting to force developers to use polyfills for the current LTS versions of major runtime environments, such as Node. @chinesedfan - apologies for tagging you in this reply, but could you please let me know which design direction you'd prefer ( Thanks, |
Node.js 16 is now LTS. Could someone from the Axios project please comment whether this issue is going to be fixed to still support node.js 14, or whether the official position is that Axios now requires node.js 15 or newer? Personally I would prefer if Axios could support node.js 14 still, especially since it's such a simple fix, and not force everyone to update to 16 the moment it became LTS. Anyway, either decision will work, but it would be nice to have a statement here, so we at least know whether to wait for a fix or whether we should start adding polyfills to make axios work with node 14. Thank you (and appreciate your work on Axios). Matus |
Does anyone know if the PR is going to be merge soon? #4229 |
+1 This is causing an issue when upgrading This solution allows upgrading to the latest version of axios without forcing an upgrade to Node v16, which is important. |
Any chance a fix will be merged soon? Is there anything we can do to help? :) |
+1 |
Related axios/axios#4124 closes #1223
Describe the bug
Axios has been using the
AbortController
from the DOM library since version 0.22.0 (# 3305). Since then, the DOM library has to be stored in tsconfig.json. Without DOM the new version is breaking for our setup and can no longer be used.To Reproduce
Use
axios.get()
without DOM Library. To reproduce changetsconfig.json
to eg.:Expected behavior
axios should work without DOM. Maybe there is an alternative for
AbortController
?Environment
Additional context/Screenshots
Given Exception:
The text was updated successfully, but these errors were encountered: