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

req.destroy / req.abort does not close the underlying connection #26

Closed
goloroden opened this issue Sep 21, 2015 · 8 comments
Closed

req.destroy / req.abort does not close the underlying connection #26

goloroden opened this issue Sep 21, 2015 · 8 comments

Comments

@goloroden
Copy link

If you have an open request and call req.destroy(), you won't get data any longer, but the connection stays open (at least in Chrome).

So, for the server-side, there is no way to detect that the client is not interested any more in the server's data and can therefor not clean up afterwards :-(

What should I do to handle this?

@terinjokes
Copy link

In Chrome, you're likely using the WHATWG Fetch API, which currently has no way to signal an abort. See this thread: whatwg/fetch#27

@feross
Copy link
Collaborator

feross commented Sep 21, 2015

Yeah, this is a limitation of the Fetch API. Once there's support for aborting a request, we'll add support to stream-http and your server load will be magically reduced :)

@goloroden
Copy link
Author

Thanks for your very quick replies :-)

Do you know of any timeframe that we're talking about here? Is this something that is probably going to happen in the near future, or will it take its time (weeks, months, years)?

@feross
Copy link
Collaborator

feross commented Sep 21, 2015

I would guess months. It depends on it being spec'd out and implemented by browsers, so it could turn out to be years if they don't get their act together.

I asked on Twitter: https://twitter.com/feross/status/646011172970299392

@jhiesey would be able to tell you if there's an option you can pass to force stream-http to use XHR instead of Fetch so you'll get support for abort.

@goloroden
Copy link
Author

Thanks a lot for the detailed answer :-))

@jhiesey
Copy link
Owner

jhiesey commented Sep 23, 2015

There isn't currently an option to force XHR instead of Fetch, but I agree it sounds like a good idea. Pull request welcome!

Otherwise I'll add it myself sometime soon.

@goloroden
Copy link
Author

Being able to force this mode somehow is one thing, but how would you switch into this mode when using stream-http within browserify?

@jhiesey
Copy link
Owner

jhiesey commented Sep 30, 2015

@goloroden As long as you are using http directly, essentially all browserify does is change require('http') into require('stream-http'). This means that you can just pass the needed options into http.request() or http.get().

If on the other hand you are using another module that in turn requires http, then you won't necessarily have any way of passing the necessary options.

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

No branches or pull requests

4 participants