Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCloud Error: Source code size exceeds the limit

I'm doing the tutorial of basic fulfillment and conversation setup of api.ai tutorial to make a chat bot, and when I try to deploy the function with the command:

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

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

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

I've searched but not found any answer, I don't know where is the error. this is the JS file that appear 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's 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
  }));
};
like image 661
venkywonka Avatar asked Jul 14 '17 15:07

venkywonka


2 Answers

Neither of these worked for me. The way I was able to fix this was to make sure I was running the deploy from my project directory (the directory containing index.js)

like image 160
Sean Avatar answered Oct 21 '22 23:10

Sean


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

The error you see is because size of (uncompressed) files in the directory is bigger than 512MB.

The easiest way to solve this is by moving the .js file to its own directory and deploying from there (you can use --local-path to point to directory containing the source file if you want your working directory to be different from directory with function source).

like image 30
Joachim Avatar answered Oct 21 '22 23:10

Joachim