-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
support TCP_NODELAY option #1240
Conversation
I don't see a reason to add buffering delay for requests. Why do you need this? |
This is not add a delay for a request, this is support |
|
So if true is the default used by node, and therefore used by superagent, the only use for this function is to set it to false. Why would you need to set nodelay to false? |
This means the param |
Here is the source code of nodejs
|
Ah! I see. I'm sorry I misread that documentation page. I've tried this change and I tried to see how much it affects the speed, but I'm not seeing any effect: describe('benchmark', function(){
it('nodelay', function(){
this.timeout(1000000);
const https = require('https');
return Array.from(Array(100)).reduce(prev => prev.then(() => {
return request
.head('https://geekhood.net/robots.txt') // remote serv in case localhost is special
.agent(new https.Agent({ keepAlive: false }))
.set('connection', 'close')
}), Promise.resolve());
});
}); With and without nodelay I'm seeing about the same speed (tested on macOS). |
Thank you for you merged this commit and added benchmark for it.
By the way, may be it's a good choice for user (who use superagent) to choose enable |
Yes, since I didn't see any negative side effect, I've enabled it all the time just in case. As far as I understand cost/benefit of Nagle's algorithm depends on how the data is sent — whether it's sent all at once, or sent bit by bit. In case of superagent user has absolutely no control over this. All of the sending happens in Node's underlying HTTP request library. Since nodelay doesn't seem to affect anything, I presume Node already sends all headers at once. So I don't see why user would need to have control over this, since it doesn't depend on the user, but depends on Node's implementation. In case of superagent there should clearly exist a right and wrong setting, and there shouldn't be a need to let user set it to a wrong value. |
* commit '4e21f1c509c3ee09ea4031c27855ed8e9ddc0d35': Documented FormData support in .send() (#1260) Update supported node version to >= 4.0 (#1248) Keep nodelay always on support TCP_NODELAY option (#1240) timeout options.read property is not used. grammar misstype (#1234) Fix spelling mistake in the docs (#1232) Revert test 'fixes' - see PR #1227 Support passphrase with pfx certificate Fix build errors Send payload in query string for GET and HEAD shorthand API Fix xml tests that broke with mime update
Add setNoDelay method for Request, this method can enable
TCP_NODELAY
option.