gax-nodejs
gax-nodejs copied to clipboard
fix: enable keepAlive for HTTP requests
As described in https://github.com/node-fetch/node-fetch#custom-agent, the keepalive
option is not enabled by default until Node.js v19, which makes HTTP requests reconnect for each request.
In this PR I will add Node.js HTTP/HTTPS agent initialization as suggested at the link above; I'm doing it in this somewhat hacky way instead of regular import * as https from 'https'
to make sure the non-Node scenarios are not broken by this.
Let's see if it helps!