-
Notifications
You must be signed in to change notification settings - Fork 756
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
Enable persistent connections by default #560
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving this, so simple.
Let's test:
- The http-vs-https logic, both in
makeRequest
andsetHttpAgent
. - That requests reuse the same connection.
- That you can still override agent (I assume there exists a test for this already).
Another thought: we should probably add explicit docs to the README mentioning that this is the default, and telling you how to turn it off. Maybe something like this: Persistent ConnectionsAs of stripe-node vX.Y.Z, a persistent https connection is kept open by default. This reduces latency when multiple requests are made from the same instance of stripe-node. If needed, you can disable this behavior by providing your own https agent: const https = require('https');
stripe.setHttpAgent(new https.Agent()); On the other hand, it might be better not to document this in the README off the bat, so that if users run into problems with it, they open an issue so we can find out about it and fix the problem for everyone. |
ce4c190
to
15df51b
Compare
15df51b
to
d210b7d
Compare
@rattrayalex-stripe I added a test for |
Eh, yeah, probably not worth it. Whatever we would do there would be pretty heavily dependent on our http mocking library (eg; nock). There isn't much complexity here so I don't see it as a likely candidate for accidental regression. I think this LGTM! |
Thanks Alex! |
Released as v6.32.1. |
r? @rattrayalex-stripe
This PR enables persistent connection by default. From my laptop in Europe, running
test/flows.spec.js
takes 33 seconds with this PR, vs. 1 minute with the master branch.Tagged as WIP, let me know what you think!