From 5ee57e61ea677cab519563b142c8870233729fef Mon Sep 17 00:00:00 2001 From: Lee Kellogg Date: Mon, 20 Jul 2026 19:28:08 +0000 Subject: [PATCH 1/2] fix(auth): prevent node http.Agent compatibility issue with google-auth-library on Node 22+ ### Description Avoid attaching Node's legacy http.Agent to transporterOptions when running on Node 22 or higher, preventing fetch / undici breakage during STS token exchange under Workload Identity Federation (WIF). ### Scenarios Tested - Ran mocha unit tests across auth components. ### Sample Commands firebase apptesting:execute --app 1:123:android:abc TAG=agy CONV=107aa4d3-03d0-4299-afcc-27e78b24392e --- src/requireAuth.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/requireAuth.ts b/src/requireAuth.ts index e37ecf43d26..02cba647287 100644 --- a/src/requireAuth.ts +++ b/src/requireAuth.ts @@ -28,14 +28,20 @@ function getAuthClient(config: GoogleAuthOptions): GoogleAuth { return authClient; } + const nodeMajorVersion = parseInt(process.versions.node.split(".")[0], 10); + const isNode22OrHigher = !isNaN(nodeMajorVersion) && nodeMajorVersion >= 22; + const transporterOptions = isNode22OrHigher + ? config.clientOptions?.transporterOptions + : { + ...config.clientOptions?.transporterOptions, + agent: apiv2.noKeepAliveAgent, + }; + const authConfig: GoogleAuthOptions = { ...config, clientOptions: { ...config.clientOptions, - transporterOptions: { - ...config.clientOptions?.transporterOptions, - agent: apiv2.noKeepAliveAgent, - }, + ...(transporterOptions ? { transporterOptions } : {}), }, }; From d12829bf3b9d627fa8d380be1bdb09a35e1d0786 Mon Sep 17 00:00:00 2001 From: Lee Kellogg Date: Mon, 20 Jul 2026 19:32:14 +0000 Subject: [PATCH 2/2] refactor: use optional chaining on process.versions?.node per code review --- src/requireAuth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/requireAuth.ts b/src/requireAuth.ts index 02cba647287..ce4a65ad500 100644 --- a/src/requireAuth.ts +++ b/src/requireAuth.ts @@ -28,7 +28,8 @@ function getAuthClient(config: GoogleAuthOptions): GoogleAuth { return authClient; } - const nodeMajorVersion = parseInt(process.versions.node.split(".")[0], 10); + const nodeVersion = process.versions?.node; + const nodeMajorVersion = nodeVersion ? parseInt(nodeVersion.split(".")[0], 10) : 0; const isNode22OrHigher = !isNaN(nodeMajorVersion) && nodeMajorVersion >= 22; const transporterOptions = isNode22OrHigher ? config.clientOptions?.transporterOptions