Skip to content

Commit 421cb9d

Browse files
authored
Merge branch 'main' into local_builds_angular_ssr
2 parents 34ac13c + 2ad25cf commit 421cb9d

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Disable 'keep-alive' in `google-auth-library` calls to avoid `Premature close` errors on some Node versions (#10716).

src/apiv2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function proxyURIFromEnv(): string | undefined {
168168
// https://github.com/node-fetch/node-fetch/issues/1767.
169169
const httpAgentNoKeepAlive = new http.Agent({ keepAlive: false });
170170
const httpsAgentNoKeepAlive = new https.Agent({ keepAlive: false });
171-
function noKeepAliveAgent(parsedURL: URL): http.Agent | https.Agent {
171+
export function noKeepAliveAgent(parsedURL: URL): http.Agent | https.Agent {
172172
return parsedURL.protocol === "https:" ? httpsAgentNoKeepAlive : httpAgentNoKeepAlive;
173173
}
174174

src/requireAuth.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ function getAuthClient(config: GoogleAuthOptions): GoogleAuth {
2828
return authClient;
2929
}
3030

31-
authClient = new GoogleAuth(config);
31+
const authConfig: GoogleAuthOptions = {
32+
...config,
33+
clientOptions: {
34+
...config.clientOptions,
35+
transporterOptions: {
36+
...config.clientOptions?.transporterOptions,
37+
agent: apiv2.noKeepAliveAgent,
38+
},
39+
},
40+
};
41+
42+
authClient = new GoogleAuth(authConfig);
3243
return authClient;
3344
}
3445

0 commit comments

Comments
 (0)