Skip to content

fix: disable keep-alive on GoogleAuth transporter to avoid Premature … - #10717

Merged
joehan merged 1 commit into
mainfrom
fix/auth-keepalive-regression
Jun 25, 2026
Merged

joehan merged 1 commit into
mainfrom
fix/auth-keepalive-regression

Conversation

@joehan

@joehan joehan commented Jun 25, 2026

Copy link
Copy Markdown
Member

Description

Disables HTTP keep-alive on the transporter utilized by google-auth-library to fetch and exchange auth tokens (e.g. via WIF or ADC). This works around a Node.js keep-alive socket reuse regression shipped in security updates for Node 22.23.0 and Node 24.17.0 (referenced in nodejs/node#63989) which causes token exchange requests to fail with Premature close.

Fixes #10716

Scenarios Tested

Wrote up a minimal reproduction script scripts/repro.ts under Node v24.17.0 using Application Default Credentials:

  • Verified it fails on v15.22.1 and v15.22.2 (without the fix) with a Premature close GaxiosError.
  • Verified it successfully passes after applying the fix, making the Google API call and receiving a standard API response.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request disables 'keep-alive' in google-auth-library calls to prevent Premature close errors on certain Node versions. It exports noKeepAliveAgent from src/apiv2.ts and configures it in src/requireAuth.ts. The reviewer noted that setting transporterOptions directly in src/requireAuth.ts would overwrite existing transporter options, and suggested spreading config.clientOptions?.transporterOptions to preserve them.

Comment thread src/requireAuth.ts Resolved
…close errors

### Description
Disables HTTP keep-alive on the transporter utilized by `google-auth-library` to fetch and exchange auth tokens (e.g. via WIF or ADC). This works around a Node.js keep-alive socket reuse regression shipped in security updates for Node 22.23.0 and Node 24.17.0 (referenced in nodejs/node#63989) which causes token exchange requests to fail with `Premature close`.

Fixes #10716

### Scenarios Tested
Tested minimal reproduction script `scripts/repro.ts` under Node v24.17.0 using Application Default Credentials:
- Verified it fails on v15.22.1 and v15.22.2 (without the fix) with a `Premature close` GaxiosError.
- Verified it successfully passes after applying the fix, making the Google API call and receiving a standard API response.
- Ran all fast unit tests (`npm run mocha:fast`) successfully.
@joehan
joehan force-pushed the fix/auth-keepalive-regression branch from c67fccb to 83c1013 Compare June 25, 2026 17:03

@ajperel ajperel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pretty straightforward fix to the Node regression. Thanks for quickly fixing CLI!

@joehan
joehan merged commit 2ad25cf into main Jun 25, 2026
70 of 80 checks passed
@joehan
joehan deleted the fix/auth-keepalive-regression branch June 25, 2026 18:07
bkendall pushed a commit that referenced this pull request Jul 9, 2026
…close errors (#10717)

### Description
Disables HTTP keep-alive on the transporter utilized by `google-auth-library` to fetch and exchange auth tokens (e.g. via WIF or ADC). This works around a Node.js keep-alive socket reuse regression shipped in security updates for Node 22.23.0 and Node 24.17.0 (referenced in nodejs/node#63989) which causes token exchange requests to fail with `Premature close`.

Fixes #10716

### Scenarios Tested
Tested minimal reproduction script `scripts/repro.ts` under Node v24.17.0 using Application Default Credentials:
- Verified it fails on v15.22.1 and v15.22.2 (without the fix) with a `Premature close` GaxiosError.
- Verified it successfully passes after applying the fix, making the Google API call and receiving a standard API response.
- Ran all fast unit tests (`npm run mocha:fast`) successfully.
bkendall pushed a commit that referenced this pull request Jul 9, 2026
…close errors (#10717)

### Description
Disables HTTP keep-alive on the transporter utilized by `google-auth-library` to fetch and exchange auth tokens (e.g. via WIF or ADC). This works around a Node.js keep-alive socket reuse regression shipped in security updates for Node 22.23.0 and Node 24.17.0 (referenced in nodejs/node#63989) which causes token exchange requests to fail with `Premature close`.

Fixes #10716

### Scenarios Tested
Tested minimal reproduction script `scripts/repro.ts` under Node v24.17.0 using Application Default Credentials:
- Verified it fails on v15.22.1 and v15.22.2 (without the fix) with a `Premature close` GaxiosError.
- Verified it successfully passes after applying the fix, making the Google API call and receiving a standard API response.
- Ran all fast unit tests (`npm run mocha:fast`) successfully.
yuichi0301 pushed a commit to yuichi0301/firebase-tools that referenced this pull request Aug 16, 2026
…close errors (firebase#10717)

### Description
Disables HTTP keep-alive on the transporter utilized by `google-auth-library` to fetch and exchange auth tokens (e.g. via WIF or ADC). This works around a Node.js keep-alive socket reuse regression shipped in security updates for Node 22.23.0 and Node 24.17.0 (referenced in nodejs/node#63989) which causes token exchange requests to fail with `Premature close`.

Fixes firebase#10716

### Scenarios Tested
Tested minimal reproduction script `scripts/repro.ts` under Node v24.17.0 using Application Default Credentials:
- Verified it fails on v15.22.1 and v15.22.2 (without the fix) with a `Premature close` GaxiosError.
- Verified it successfully passes after applying the fix, making the Google API call and receiving a standard API response.
- Ran all fast unit tests (`npm run mocha:fast`) successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth regression in 15.22.2: ADC / Workload Identity Federation fails with "Failed to authenticate, have you run firebase login?"

2 participants