gcloud deploy function error code 3

Viewed 3631

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

gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http

(where 'testBot' is the name of the project and 'testbot-e9bc4.appspot.com' is the bucket_name, I thought..) 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
  }));
};
3 Answers

Make sure you are in the correct directory where your go code resides before executing gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http command.

I was working in the express project. In my case, I mistakenly installed the @google/storage package in devDependencies instead of dependencies. I unable to notice as I tested the project in debug mode using mocha. So in debug, it is able to find that package in devDependencies but on deploy function, it tries to find in dependencies in package.json but unable to find there.

Open command prompt at the location where index.js was created and run the above gcloud command.

Related