firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

HTTP Error: 400, Unknown Error for exceeding the Cloud Function Max deployment size #4203

Closed rscotten closed 2 years ago

rscotten commented 2 years ago

[REQUIRED] Environment info

firebase-tools: 9.16.5

Platform: macOS

[REQUIRED] Test case

Unnecessary for this bug; just improve the server-side error messaging.

[REQUIRED] Steps to reproduce

The Cloud Function Max Deployment size is:

100MB (compressed) for sources. 500MB (uncompressed) for sources plus modules

Source

When exceeding this, the Firebase CLI error is:

Error: HTTP Error: 400, Unknown Error

Screen Shot 2022-02-22 at 7 47 30 AM

[REQUIRED] Expected behavior

Error: HTTP Error: 4xx, Exceeded Cloud Function max deployment size of 100MB (compressed) for sources

or

Error: HTTP Error: 4xx, Exceeded Cloud Function max deployment size of 500MB (uncompressed) for sources plus modules

[REQUIRED] Actual behavior

Error: HTTP Error: 400, Unknown Error

bkendall commented 2 years ago

I believe #4180 helped to address this - if you update to the latest firebase-tools, you should see different error messaging. @taeold to confirm...

taeold commented 2 years ago

@bkendall @rscotten That's right. The latest release should give you slightly better error message, e.g.

⚠  functions: Upload Error: HTTP Error: 400, <?xml version='1.0' encoding='UTF-8'?><Error><Code>EntityTooLarge</Code><Message>Your proposed upload is larger than the maximum object size specified in your Policy Document.</Message><Details>Content-length exceeds upper bound on range</Details></Error>

Error: HTTP Error: 400, <?xml version='1.0' encoding='UTF-8'?><Error><Code>EntityTooLarge</Code><Message>Your proposed upload is larger than the maximum object size specified in your Policy Document.</Message><Details>Content-length exceeds upper bound on range</Details></Error>

Can you give the latest version a spin and let us know?

rscotten commented 2 years ago

@bkendall @taeold

I updated to version 10.2.1 and got the same "Unknown Error" error:

Screen Shot 2022-02-22 at 12 45 27 PM
taeold commented 2 years ago

@rscotten Thanks for taking the time! I'll try to see what I missed in my last round 🤔

If you have sometime, I'd really appreciate if you can share the output of runnign firebase deploy --only:functions --debug (with the --debug flag) 🙏🏼 .

rscotten commented 2 years ago

@taeold

[2022-02-22T19:07:38.053Z] <<< HTTP RESPONSE 400 {"x-guploader-uploadid":"ADPycduMm0k6yHhvscO9vrWUUoDtVG_Me2shMah6oVQlDadgav9LAZTVuEzKBmndcLt4eLhaMc-X_p0g_wUvMZpETrc","content-type":"application/xml; charset=UTF-8","content-length":"255","vary":"Origin","date":"Tue, 22 Feb 2022 19:07:38 GMT","server":"UploadServer","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":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\""}
[2022-02-22T19:07:38.056Z] <<< HTTP RESPONSE BODY <?xml version='1.0' encoding='UTF-8'?><Error><Code>EntityTooLarge</Code><Message>Your proposed upload is larger than the maximum object size specified in your Policy Document.</Message><Details>Content-length exceeds upper bound on range</Details></Error>
⚠  functions: Upload Error: HTTP Error: 400, Unknown Error 

Error: HTTP Error: 400, Unknown Error
[2022-02-22T19:07:38.181Z] Error Context: {
  "body": {
    "error": {
      "message": "Unknown Error"
    }
  },
  "response": {
    "statusCode": 400,
    "body": "<?xml version='1.0' encoding='UTF-8'?><Error><Code>EntityTooLarge</Code><Message>Your proposed upload is larger than the maximum object size specified in your Policy Document.</Message><Details>Content-length exceeds upper bound on range</Details></Error>",
    "headers": {
      "x-guploader-uploadid": "ADPycduMm0k6yHhvscO9vrWUUoDtVG_Me2shMah6oVQlDadgav9LAZTVuEzKBmndcLt4eLhaMc-X_p0g_wUvMZpETrc",
      "content-type": "application/xml; charset=UTF-8",
      "content-length": "255",
      "vary": "Origin",
      "date": "Tue, 22 Feb 2022 19:07:38 GMT",
      "server": "UploadServer",
      "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":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\""
    },
    "request": {
      "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "storage.googleapis.com",
        "port": 443,
        "hostname": "storage.googleapis.com",
        "hash": null,
        "search": "?GoogleAccessId=service-21372694838@gcf-admin-robot.iam.gserviceaccount.com&Expires=1645558568&Signature=pCEZbgfHQ27KjytcSehUimbtpEio0NEEmEf1LTxDVMPLHHZKBkTfKnehSctngh9CdK55qgXOECoxBsddUw8jWjjFc7dL0XHkomcJ52e20u3k%2FG1ipyLNU1jOxZbizffT396VTOpMPy4UbEkFPG5J6VANzAZa61qdF5VHjonJZAVb9iOOloFYiqcc8Y%2FUvN%2BeiT0Jm9kvGTLNiAcJtE7CSNx6SvY5nKQIiD9hFDaGNjJyYGlR9ppc%2Bppc1CHJVRjgzcCc98I2eW%2FQViLj0wMyhP3e%2BZIKIayB2RJBjqS5RJaudH7U0TlDQNeELjAR4YSvGmEhOicq6Tz1xL8jc9uprA%3D%3D",
        "query": "GoogleAccessId=service-21372694838@gcf-admin-robot.iam.gserviceaccount.com&Expires=1645558568&Signature=pCEZbgfHQ27KjytcSehUimbtpEio0NEEmEf1LTxDVMPLHHZKBkTfKnehSctngh9CdK55qgXOECoxBsddUw8jWjjFc7dL0XHkomcJ52e20u3k%2FG1ipyLNU1jOxZbizffT396VTOpMPy4UbEkFPG5J6VANzAZa61qdF5VHjonJZAVb9iOOloFYiqcc8Y%2FUvN%2BeiT0Jm9kvGTLNiAcJtE7CSNx6SvY5nKQIiD9hFDaGNjJyYGlR9ppc%2Bppc1CHJVRjgzcCc98I2eW%2FQViLj0wMyhP3e%2BZIKIayB2RJBjqS5RJaudH7U0TlDQNeELjAR4YSvGmEhOicq6Tz1xL8jc9uprA%3D%3D",
        "pathname": "/gcf-upload-us-central1-f0c7a74e-bccd-4ed6-9514-fc5a1f24dd94/9fa1893c-28fa-410f-bd6b-ce2621b78b34.zip",
        "path": "/gcf-upload-us-central1-f0c7a74e-bccd-4ed6-9514-fc5a1f24dd94/9fa1893c-28fa-410f-bd6b-ce2621b78b34.zip?GoogleAccessId=service-21372694838@gcf-admin-robot.iam.gserviceaccount.com&Expires=1645558568&Signature=pCEZbgfHQ27KjytcSehUimbtpEio0NEEmEf1LTxDVMPLHHZKBkTfKnehSctngh9CdK55qgXOECoxBsddUw8jWjjFc7dL0XHkomcJ52e20u3k%2FG1ipyLNU1jOxZbizffT396VTOpMPy4UbEkFPG5J6VANzAZa61qdF5VHjonJZAVb9iOOloFYiqcc8Y%2FUvN%2BeiT0Jm9kvGTLNiAcJtE7CSNx6SvY5nKQIiD9hFDaGNjJyYGlR9ppc%2Bppc1CHJVRjgzcCc98I2eW%2FQViLj0wMyhP3e%2BZIKIayB2RJBjqS5RJaudH7U0TlDQNeELjAR4YSvGmEhOicq6Tz1xL8jc9uprA%3D%3D",
        "href": "https://storage.googleapis.com/gcf-upload-us-central1-f0c7a74e-bccd-4ed6-9514-fc5a1f24dd94/9fa1893c-28fa-410f-bd6b-ce2621b78b34.zip?GoogleAccessId=service-21372694838@gcf-admin-robot.iam.gserviceaccount.com&Expires=1645558568&Signature=pCEZbgfHQ27KjytcSehUimbtpEio0NEEmEf1LTxDVMPLHHZKBkTfKnehSctngh9CdK55qgXOECoxBsddUw8jWjjFc7dL0XHkomcJ52e20u3k%2FG1ipyLNU1jOxZbizffT396VTOpMPy4UbEkFPG5J6VANzAZa61qdF5VHjonJZAVb9iOOloFYiqcc8Y%2FUvN%2BeiT0Jm9kvGTLNiAcJtE7CSNx6SvY5nKQIiD9hFDaGNjJyYGlR9ppc%2Bppc1CHJVRjgzcCc98I2eW%2FQViLj0wMyhP3e%2BZIKIayB2RJBjqS5RJaudH7U0TlDQNeELjAR4YSvGmEhOicq6Tz1xL8jc9uprA%3D%3D"
      },
      "method": "PUT"
    }
  }
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ firebase -V
10.2.1
taeold commented 2 years ago

@rscotten Huh I'm baffled. On my machine, the XML error does log nicely 🤔

Going to go off to see if I'm just a little too tired and now seeing an obvious bug.

thanishahamed commented 2 years ago

@rscotten

I faced the same issue,

I tried the followings.

then,

And deployed my nextjs to the firebase function.

This reduced 117MB upload file size to 11 MB file size and successfully deployed.

Thank You!

MorenoMdz commented 2 years ago

Had the same issue, which in our case was caused by Prod backups we had in the local export folder we use. Removing that data fixed the deploy payload size issue.

joehan commented 2 years ago

Hey all, I'm going to close this since the error message is now more clear, and we don't have control over the max cloud functions upload size. If you run into this issue, please double check that you are not including anything unnecessary in the deployment

kmiterror commented 1 year ago

I had the same problem, size of my package was around 140MB. Week ago it was closer to 40MB. As I found, the problem might be with the ignore section in firebase.json As per this comment https://github.com/firebase/firebase-tools/issues/1602#issuecomment-521765506 it seems that ignore is not additive.

This means that if anything is specified in ignore section, default values are not included anymore therefore node_modules is not excluded from the package, and this in turn means that the packages size gets very big. So the solution is to specify "**/node_modules/**" in ignore section. When I did this my package size went down from 140MB to 290KB.

"ignore": [
      "src/functions/views/**",
      "**/node_modules/**"
    ]