GCloud error: source code size exceeds limit

I am doing a basic execution and conversation setup api.ai tutorial to make a chatbot and when I try to deploy the function using the command:

gcloud beta functions deploy --stage-bucket venky-bb7c4.appspot.com --trigger-http

      

(where "venky-bb7c4.appspot.com" is the bucket_name) It returns the following error message:

ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Source code size exceeds the limit

      

I searched but did not find an answer, I do not know where the error is. this is the JS file that appears in the tutorial:

    /
 HTTP Cloud Function.

 @param {Object} req Cloud Function request context.
 @param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
  response = "This is a sample response from your webhook!" //Default response from the webhook to show it working


res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
  res.send(JSON.stringify({ "speech": response, "displayText": response 
  //"speech" is the spoken version of the response, "displayText" is the visual version
  }));
};

      

+3


source to share


3 answers


The command creates a zip with the contents of your entire current directory (except the node_modules subdirectory), not just the JS file (this is because your function may use other resources).

The error you are seeing is that the size of the (uncompressed) files in the directory is greater than 512 MB.



The easiest way to solve this is to move the .js file to your own directory and deploy there (you can use --local-path

to specify the directory containing the source file if you want your working directory to be different from the function's source directory).

+2


source


Make sure the package folder has a .gitignore file (excluding node_modules).

The most recent version of gcloud requires it to avoid loading node_modules. My code size ranged from 119MB to 17KB.



As soon as I added the .gitignore file, the log also printed

created .gcloudignore file. See `gcloud topic gcloudignore` for details.

      

0


source


None of them worked for me. The way I was able to fix this was to make sure I was launching the deployment from the project directory (the directory containing index.js)

0


source







All Articles