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

Add keep-alive support #950

Closed
bcanseco opened this issue Jul 3, 2019 · 4 comments
Closed

Add keep-alive support #950

bcanseco opened this issue Jul 3, 2019 · 4 comments
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@bcanseco
Copy link

bcanseco commented Jul 3, 2019

Issue Summary

First off: this repo (and Sendgrid overall) is fantastic! ❤️

I'm using @sendgrid/mail and was interested in the behavior for handling keep-alive.
I noticed that the core @sendgrid/client package uses the request library behind the scenes to hit the API.

const http = require('request');

http(request, (error, response, body) => {

There's a forever option that could be set to true in the defaultRequest configuration.

this.defaultRequest = {
json: true,
baseUrl: 'https://api.sendgrid.com/',
url: '',
method: 'GET',
headers: {},
};

This would enable keepAlive in the underlying http(s) agent.

Prior art

  • Stripe's Node.js library uses keep-alive in the underlying http(s) agent by default
  • Twilio does too, but requires opt-in [1] [2] which is probably what we would want to do here

Further reading

@marcghorayeb
Copy link

marcghorayeb commented Nov 20, 2019

I was looking for this as well. I looked a bit through the code and turns out, you can do this programmatically:

const httpsAgent = https.Agent({ maxSockets: 20, keepAlive: true, ...options });
SendGrid.client.setDefaultRequest('agent', httpsAgent);

A built-in option would be appreciated. Also, the typescript typing aren't valid for this approach, they need to be updated.

@childish-sambino childish-sambino added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Mar 3, 2020
@childish-sambino
Copy link
Contributor

Pull requests to add this feature are welcome and will be reviewed based on priority, but Twilio SendGrid is not actively building new functionality for the library.

@thinkingserious
Copy link
Contributor

Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!

@bcanseco
Copy link
Author

@thinkingserious Oh lol I completely forgot about this issue. Now that I work at Twilio maybe I'll guest engineer this at some point 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants