Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function deployment fails when running on Node 15.8.0 #3120

Closed
busiest-beaver opened this issue Feb 8, 2021 · 24 comments · Fixed by #3140
Closed

Function deployment fails when running on Node 15.8.0 #3120

busiest-beaver opened this issue Feb 8, 2021 · 24 comments · Fixed by #3140

Comments

@busiest-beaver
Copy link

[REQUIRED] Environment info

firebase-tools: 9.3.0
Node Version: 15.8.0
Platform: Linux 5.4.89-1-MANJARO

[REQUIRED] Test case

Deploy the function generated initially when you run firebase init and select functions.

// index.js
const functions = require("firebase-functions");
exports.helloWorld = functions.https.onRequest((request, response) => {
	functions.logger.info("Hello logs!", {structuredData: true});
	response.send("Hello from Firebase!");
});

[REQUIRED] Steps to reproduce

Deploy the function above:

$ firebase deploy --only "functions:helloWorld"

[REQUIRED] Expected behavior

Expected behavior is to deploy the function(s) without any errors.

[REQUIRED] Actual behavior

Deployments fails with the following output message in local terminal:

$ firebase deploy --only "functions:helloWorld"

=== Deploying to 'test-functions-d4276'...

i  deploying functions
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
⚠  functions: missing required API cloudbuild.googleapis.com. Enabling now...
✔  functions: required API cloudbuild.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (41.36 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: uploading functions in project: helloWorld(us-central1)
i  functions: creating Node.js 12 function helloWorld(us-central1)...
⚠  functions[helloWorld(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/...


Functions deploy had errors with the following functions:
        helloWorld


To try redeploying those functions, run:
    firebase deploy --only "functions:helloWorld"


To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

Having trouble? Try firebase [command] --help

Cloud console had the following output in log explorer:

{
	"textPayload": "ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1",
	"insertId": "07530e91-3ce1-44c5-88a7-b8025758115c-27",
	"resource": {
		"type": "build",
		"labels": {
			"project_id": "test-functions-d4276",
			"build_id": "07530e91-3ce1-44c5-88a7-b8025758115c",
			"build_trigger_id": ""
		}
	},
	"timestamp": "2021-02-08T22:48:26.709353507Z",
	"severity": "INFO",
	"labels": {
		"build_step": "MAIN"
	},
	"logName": "projects/test-functions-d4276/logs/cloudbuild",
	"receiveTimestamp": "2021-02-08T22:48:26.906497807Z"
}

Workaround

I switched to Node version 14.x.x and everything worked fine. This may be a duplicate of #3108. The SO link they provided also has more details so it might be worth looking into. In #3108 they seem to have trouble deploying with node versions aside from 15.x.x. They mention that deploy requires keyboard input in GCP; in my logs this does show up but seems selects an input automatically anyway, the selected input being [N]one. I am listing the summary for this particular log message below. Note, this happens before the error message I attached farther up the document.

{
  "textPayload": "replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename:  NULL",
  "insertId": "07530e91-3ce1-44c5-88a7-b8025758115c-16",
  "resource": {
    "type": "build",
    "labels": {
      "build_id": "07530e91-3ce1-44c5-88a7-b8025758115c",
      "project_id": "test-functions-d4276",
      "build_trigger_id": ""
    }
  },
  "timestamp": "2021-02-08T22:48:20.754221592Z",
  "severity": "INFO",
  "labels": {
    "build_step": "gsutil:STDERR"
  },
  "logName": "projects/test-functions-d4276/logs/cloudbuild",
  "receiveTimestamp": "2021-02-08T22:48:21.560769220Z"
}

Followed by:

{
  "textPayload": "(EOF or read error, treating as \"[N]one\" ...)",
  "insertId": "07530e91-3ce1-44c5-88a7-b8025758115c-17",
  "resource": {
    "type": "build",
    "labels": {
      "build_trigger_id": "",
      "build_id": "07530e91-3ce1-44c5-88a7-b8025758115c",
      "project_id": "test-functions-d4276"
    }
  },
  "timestamp": "2021-02-08T22:48:20.754274058Z",
  "severity": "INFO",
  "labels": {
    "build_step": "gsutil:STDERR"
  },
  "logName": "projects/test-functions-d4276/logs/cloudbuild",
  "receiveTimestamp": "2021-02-08T22:48:21.560769220Z"
}
@jimmont
Copy link

jimmont commented Feb 10, 2021

+1 Same issue, v15, which is what (was) available on the M1 apple-silicon brew installery of late, leading to the this workflow (here) HTH. What a curiosity these errors. Supporting a vendor's software....

@AQuackenbos
Copy link

+1, also seeing this issue on Node v15.8.0

@taeold
Copy link
Contributor

taeold commented Feb 11, 2021

Hi folks - we are actively taking a look at the issue. Stay tuned.

@taeold
Copy link
Contributor

taeold commented Feb 12, 2021

It looks like the issue is related to archiverjs/node-archiver#491.

They've patched up the issue, but we are using an older version of archiver that did not receive the patch. We'll need to try updating the archiver version and make sure nothing breaks.

Anyone interesting in helping with the changes?

@Yorzic
Copy link

Yorzic commented Feb 13, 2021

Thank you, @taeold! When do you expect you'll release an updated version?

@approached
Copy link

I' am use M1 apple-silicon to.
With node >14 version firebase-tool doesnt works. I have same error like #3129
With version 15 it works but i am frustrated on the deploy. The deployment is not possible.

I'am am waiting for your update 🥇

@taeold
Copy link
Contributor

taeold commented Feb 16, 2021

Patch submitted. It will be included in the next release for firebaes-tools package (AFAIK we don't have a regular release schedule, but we do get out a release ~once a week).

@taeold
Copy link
Contributor

taeold commented Feb 17, 2021

The fix is available in the latest firebase-tools package (>9.4.0).

@sudcha23
Copy link

The fix is available in the latest firebase-tools package (>9.4.0).

@taeold this still doesn't fix the Google Cloud Builds for Firebase functions CICD. I'm getting same error during Cloud Build.
Any idea how to solve that, or if there will be a fix?

@kmcnellis
Copy link
Member

This seems to have fixed the issue on x64 binaries, but not on arm

@kmcnellis kmcnellis reopened this Feb 23, 2021
@taeold
Copy link
Contributor

taeold commented Feb 25, 2021

@kmcnellis Based on my reading of #3129, I'm a bit confused. Are you saying that:

  1. M1 running the firebase-cli built for x86 (rosetta) fails to deploy CF3s
  2. M1 running the firebase-cli built for ARM fails to deploy CF3s

If (1), then we should focus on resolving #3129 not this issue.

@taeold
Copy link
Contributor

taeold commented Feb 25, 2021

@sudcha23 Can you share the error messages you are seeing in your Cloud Build setup? Are you seeing the same error message as described in the original issue description? If so, I don't have a clue what's going on and will have to find a way to reproduce the error you are seeing.

@kmcnellis
Copy link
Member

It's (2) M1 running the firebase-cli built for ARM fails to deploy CF3s

When it runs the x86 binaries (1), the deploy works fine.

@kmcnellis
Copy link
Member

The error is:

[2021-02-26T01:23:48.700Z] <<< HTTP RESPONSE 200 {"content-type":"application/json; charset=UTF-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","date":"Fri, 26 Feb 2021 01:23:48 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
⚠  functions[addNumbers2(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=kmcnellis-quickstart&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3Da745f698-88bf-4073-a067-a7f6bd46b423%0AlogName%3Dprojects%2Fkmcnellis-quickstart%2Flogs%2Fcloudbuild

In the cloud build logs:

google.devtools.cloudbuild.v1.CloudBuild.GetBuild
projects/kmcnellis-quickstart/builds/a745f698-88bf-4073-a067-a7f6bd46b423
audit_log, method: "google.devtools.cloudbuild.v1.CloudBuild.GetBuild", principal_email: ""
starting build "a745f698-88bf-4073-a067-a7f6bd46b423"
FETCHSOURCE
Fetching storage object: gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676
google.devtools.cloudbuild.v1.CloudBuild.GetBuild
projects/kmcnellis-quickstart/builds/a745f698-88bf-4073-a067-a7f6bd46b423
audit_log, method: "google.devtools.cloudbuild.v1.CloudBuild.GetBuild", principal_email: ""
Copying gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676...
/ [0 files][    0.0 B/ 70.1 KiB]                                                
/ [1 files][ 70.1 KiB/ 70.1 KiB]                                                
Operation completed over 1 objects/70.1 KiB.
Archive: /tmp/source-archive.zip
inflating: /workspace/.runtimeconfig.json inflating: /workspace/.eslintrc.json
inflating: /workspace/.gitignore
inflating: /workspace/.zprofile
  inflating: /workspace/Brewfile      
inflating: /workspace/index.js
bad CRC e0fcdf93 (should be 00000000)
inflating: /workspace/package-lock.json
inflating: /workspace/package.json
inflating: /workspace/sanitizer.js
Fetching storage object: gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676
google.devtools.cloudbuild.v1.CloudBuild.GetBuild
projects/kmcnellis-quickstart/builds/a745f698-88bf-4073-a067-a7f6bd46b423
audit_log, method: "google.devtools.cloudbuild.v1.CloudBuild.GetBuild", principal_email: ""
Copying gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676...
/ [0 files][ 0.0 B/ 70.1 KiB] / [1 files][ 70.1 KiB/ 70.1 KiB]
Operation completed over 1 objects/70.1 KiB.
replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)
Archive: /tmp/source-archive.zip
Fetching storage object: gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676
Copying gs://gcf-sources-21021519179-us-central1/addNumbers2-f32732e3-26b5-4585-a1ab-a0bbefbf1670/version-13/function-source.zip#1614302603664676...
/ [0 files][ 0.0 B/ 70.1 KiB] / [1 files][ 70.1 KiB/ 70.1 KiB]
Operation completed over 1 objects/70.1 KiB.
replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)
Archive: /tmp/source-archive.zip
ERROR
ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1

@taeold
Copy link
Contributor

taeold commented Feb 27, 2021

Seeing bad ZIP archives again in #3120 (comment):

bad CRC e0fcdf93 (should be 00000000)

This error was exactly what we hoped to fix with #3140. At the end of the day, we expect the crc32-stream package includes archiverjs/node-crc32-stream#31 (we need to use version 4.0.2 of this package).

I'm not sure whether the latest version of the crc32-stream package (v4.0.2) still doesn't fix the issue for M1 Macs, or the issue lies somewhere else. Since I don't have a M1 Mac, I'm going to keep asking you both @kmcnellis @donhmorris more questions (sorry :'( ).

Can you check the version of crc32-stream package you are currently using. Assuming that you are using nvm and downloaded firebase cli via npm -g install firebase-tools, I think you will find the version in /path/to/.nvm/versions/node/v14.0.0/lib/node_modules/firebase-tools/node_modules/crc32-stream/package.json.

@kmcnellis
Copy link
Member

Hm, I uninstalled node & firebase fully before checking that, and I can't replicate anymore. Maybe @donhmorris can?

@innovation-club-net
Copy link

I have the same error trying to follow https://cloud.google.com/build/docs/deploying-builds/deploy-firebase
with

  - name: gcr.io/<projectid>/firebase
    args: ['deploy', '--project=<projectid>', '--only=functions']
replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)
Archive: /tmp/source-archive.zip
ERROR
ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1

I basically have no control on the architecture/hardware as I am using cloud build's one.
Workaround for me so far is using

  - name: "gcr.io/cloud-builders/gcloud"
    args:
      - functions
      - deploy

Note that deploying storage works

  - name: gcr.io/<projectid>/firebase
    args: ['deploy', '--project=<projectid>', '--only=storage']

Local hardware is Mac x64 but so far I understand my issue, this is irrelevant.
I am using node 12.

@donhmorris
Copy link

I think you guys have moved beyond my knowledge of the firebase cli. I have never dug into the code for it.

@taeold
Copy link
Contributor

taeold commented Mar 1, 2021

@innovation-club-net Can you open up a new issue with the appropriate details (e.g. version of the firesbase cli and debug logs would be helpful)? You are using node12, and I'd like to use this issue to track deployment issues for node15.

@donhmorris
Copy link

Here are my steps I followed several times with the same results:

  • start with a virgin m1 macbook air with the exception of installing google chrome
  • install xcode, wait forever 😀
  • run xcode to have it do its thing
  • install nvm using curl
  • install node 15 using nvm, wait forever while it build node
  • test node by running command node --version
  • make sure npm 6+ was installed instead of 7. install npm 6 if 7 is being used
  • use npm to install @angular/cli firebase-tools typescript @ionic/cli parcel-bundler svgo gcloud globally
  • sign into gcloud
  • verify all of the packages i install by running them with out arguments

I have found you are asking for a headache if you don't install xcode first. For example, git comes from xcode. xcode does some things to your mac when you run it to get things setup for development.

I have done this process 3 times

This was referenced Mar 12, 2021
@harihara6
Copy link

I have the same error trying to follow https://cloud.google.com/build/docs/deploying-builds/deploy-firebase
with

  - name: gcr.io/<projectid>/firebase
    args: ['deploy', '--project=<projectid>', '--only=functions']
replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)
Archive: /tmp/source-archive.zip
ERROR
ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1

I basically have no control on the architecture/hardware as I am using cloud build's one.
Workaround for me so far is using

  - name: "gcr.io/cloud-builders/gcloud"
    args:
      - functions
      - deploy

Note that deploying storage works

  - name: gcr.io/<projectid>/firebase
    args: ['deploy', '--project=<projectid>', '--only=storage']

Local hardware is Mac x64 but so far I understand my issue, this is irrelevant.
I am using node 12.

any luck?

@taeold
Copy link
Contributor

taeold commented Jun 25, 2021

@harihara6 The problem you described depends on the version of node and firebase-cli in your builder image. Please share your setup - I've been unable to reproduce the issue (using node 16 in my builder image).

@google-oss-bot
Copy link
Contributor

Hey @alsohas. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Contributor

Since there haven't been any recent updates here, I am going to close this issue.

@alsohas if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

jethron added a commit to jethron/hoverboard that referenced this issue Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment