Skip to content
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

destroy() is not properly handled #227

Open
Niehno opened this issue Apr 26, 2023 · 0 comments
Open

destroy() is not properly handled #227

Niehno opened this issue Apr 26, 2023 · 0 comments
Labels

Comments

@Niehno
Copy link

Niehno commented Apr 26, 2023

Since node version 14 the method abort() within class http.ClientRequest is deprecated. The associated event abort has also been deprecated in the meantime.
According to the docs, one should use destroy() instead, to abort a request prematurely.

However, in contrast to abort(), the method destroy() is unfortunately not overridden and properly implemented in RedirectableRequest, which means that the _currentRequest of the redirecting chain is not terminated.

Adding the following lines as a quick fix solves the problem, but should certainly be implemented in a better way:

RedirectableRequest.prototype.destroy = function () {
    this.abort();
    Writable.prototype.destroy.call(this);
};

I just call this.abort(), to:

  1. Abort the _currentRequest. -> It would be better to call destroy() on the _currentRequest.
  2. Emit an abort event. -> Should be removed but is necessary in the quick fix so that here clearTimer() is called.

I'm using node v18 and the http client Axios, which in turn uses follow-redirects, which is how I noticed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants