[REQUIRED] Environment info
firebase-tools: 15.22.0
Official Docker image: us-docker.pkg.dev/firebase-cli/us/firebase:15.22.0
Platform: Cloud Build (Linux, official Firebase CLI Docker image)
[REQUIRED] Test case
Run a read-only Firebase Hosting command from Cloud Build using the official Firebase CLI Docker image.
No deploy command is required to reproduce this issue.
[REQUIRED] Steps to reproduce
Use a Cloud Build config like this, with a service account that has the required Firebase Hosting read permissions:
serviceAccount: "projects/<PROJECT_ID>/serviceAccounts/<SERVICE_ACCOUNT>"
steps:
- name: "us-docker.pkg.dev/firebase-cli/us/firebase:15.21.0"
entrypoint: "bash"
args:
- "-c"
- |
firebase --version
firebase hosting:sites:list --project <PROJECT_ID> --debug
- name: "us-docker.pkg.dev/firebase-cli/us/firebase:15.22.0"
entrypoint: "bash"
args:
- "-c"
- |
firebase --version
firebase hosting:sites:list --project <PROJECT_ID> --debug
options:
logging: CLOUD_LOGGING_ONLY
[REQUIRED] Expected behavior
firebase hosting:sites:list --project <PROJECT_ID> --debug should successfully list Hosting sites, as it does with firebase-tools 15.21.0.
[REQUIRED] Actual behavior
With the same Cloud Build environment and same service account:
| Image |
Result |
us-docker.pkg.dev/firebase-cli/us/firebase:15.21.0 |
Success |
us-docker.pkg.dev/firebase-cli/us/firebase:15.22.0 |
Fails with FetchError: Premature close |
Sanitized debug log excerpt from 15.21.0:
firebase --version
15.21.0
>>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/<PROJECT_ID>/sites pageToken=&pageSize=10
<<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/<PROJECT_ID>/sites 200
Sites for project <PROJECT_ID>
Sanitized debug log excerpt from 15.22.0:
firebase --version
15.22.0
[iam] error while checking permissions, command may fail:
FetchError: Invalid response body while trying to fetch
https://cloudresourcemanager.googleapis.com/v1/projects/<PROJECT_ID>:testIamPermissions:
Premature close
>>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/<PROJECT_ID>/sites pageToken=&pageSize=10
Error: FetchError: Invalid response body while trying to fetch
https://firebasehosting.googleapis.com/v1beta1/projects/<PROJECT_ID>/sites?pageToken=&pageSize=10:
Premature close
Additional investigation
This seems unrelated to Firebase Hosting deploy files, because the read-only hosting:sites:list command reproduces the issue.
The error appears while reading Google API responses in the official Docker image. The same command succeeds with 15.21.0 and fails with 15.22.0 under the same Cloud Build/service account conditions.
Looking at node-fetch, Premature close appears to be emitted when a chunked response without content-length is closed before the response body stream finishes. I am not sure whether the root cause is in the Docker image dependency set, Node/npm runtime, or something else in the 15.22.0 image, but the behavior started after moving from 15.21.0 to 15.22.0.
Workaround
Pin the Firebase CLI Docker image to 15.21.0 instead of using latest or 15.22.0.
[REQUIRED] Environment info
firebase-tools: 15.22.0
Official Docker image:
us-docker.pkg.dev/firebase-cli/us/firebase:15.22.0Platform: Cloud Build (Linux, official Firebase CLI Docker image)
[REQUIRED] Test case
Run a read-only Firebase Hosting command from Cloud Build using the official Firebase CLI Docker image.
No deploy command is required to reproduce this issue.
[REQUIRED] Steps to reproduce
Use a Cloud Build config like this, with a service account that has the required Firebase Hosting read permissions:
[REQUIRED] Expected behavior
firebase hosting:sites:list --project <PROJECT_ID> --debugshould successfully list Hosting sites, as it does withfirebase-tools15.21.0.[REQUIRED] Actual behavior
With the same Cloud Build environment and same service account:
us-docker.pkg.dev/firebase-cli/us/firebase:15.21.0us-docker.pkg.dev/firebase-cli/us/firebase:15.22.0FetchError: Premature closeSanitized debug log excerpt from 15.21.0:
Sanitized debug log excerpt from 15.22.0:
Additional investigation
This seems unrelated to Firebase Hosting deploy files, because the read-only
hosting:sites:listcommand reproduces the issue.The error appears while reading Google API responses in the official Docker image. The same command succeeds with
15.21.0and fails with15.22.0under the same Cloud Build/service account conditions.Looking at
node-fetch,Premature closeappears to be emitted when a chunked response withoutcontent-lengthis closed before the response body stream finishes. I am not sure whether the root cause is in the Docker image dependency set, Node/npm runtime, or something else in the 15.22.0 image, but the behavior started after moving from 15.21.0 to 15.22.0.Workaround
Pin the Firebase CLI Docker image to
15.21.0instead of usinglatestor15.22.0.