AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript
MIT License
268 stars 58 forks source link

Implement Abort Signal to cancel all requests on demand #138

Closed AleksandrRogov closed 1 year ago

AleksandrRogov commented 1 year ago

Implement Abort Signal that cancels an active request. This is a crucial feature and will require changes in the core modules: xhr and http.

Main question: should the cancellation signal be implemented using the AbortController or should it be a custom one? Is it even possible to depend on AbortController in all cases?

Another thing: inclusion of AbortController will require to have a minimum version of Node.js to be 15.0.0. Is it acceptable? How many environments have older versions of Node.js and if they do, why?

AleksandrRogov commented 1 year ago

Since the last LTS version of Node.js that does not support AbortController will be out of maintenance on April 30, 2023, I don't see a reason to add support for a request cancellation feature for Node.js v14 and older.

The only thing that needs to be taken care of is that DynamicsWebApi should still be usable in older versions of Node but without a cancellation feature. Which means, there needs to be a version check for Node.js and if that feature is attempted to be used in v14 and older throw an error message: "Request cancellation is not supported in your version of Node.js. Minimum version requirement is 15.0.0.".

Thus, AbortController will be used to cancel active requests in Node.js and a Browser. Need to research Browser version limitations next.