Kristopher Chayadi
Kristopher Chayadi

Reputation: 71

Deploying Function Error on Cloud Function with error code 13 and Message "INTERNAL"

I'm deploying a Firestore trigger onCreate for my App, but everytime I want to deploy, it always Error

the console always showing Code 13 and Message "INTERNAL"

this is what comes up on Console

{"@type":"type.googleapis.com/google.cloud.audit.AuditLog",
"status":{"code":13,"message":"INTERNAL"},
"authenticationInfo":{"principalEmail":"[My_EMAIL]"},
"requestMetadata":{"requestAttributes":{},"destinationAttributes":{}},
"serviceName":"cloudfunctions.googleapis.com",
"methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
"resourceName":"projects/etalase/locations/us-central1/functions/onNewMessage"}

this is my code on index.js

exports.onNewMessage = functions.firestore
  .document('/messages/{groupChatId}/{groupChatId}/{messageFeedItem}')
  .onCreate(async (snapshot, context) => {
    const doc = snapshot.data();

    console.log('------Message Created-----');
    console.log(doc);

    const idForm = doc.userID;
    const idTo = doc.sellerID;

    console.log('Message from : ', idForm);
    console.log('Message to : ', idTo);

  });

I expect this will deploy and every time a new message created on {messageFeedItem}, it will trigger the console, but even I can't deploy it

Thank you

Upvotes: 3

Views: 3154

Answers (5)

Acid Coder
Acid Coder

Reputation: 2746

my issue is because I use - character in my wild card

'chat/{abc-efg}'

I change - to _ and it works

Upvotes: 0

julianH
julianH

Reputation: 119

For anyone who got this far and still does not have a solution - here is what was wrong in my case

exports.fnName = functions.firestore
  .document('Collection/{collId}/SubCollection/{subCollId')
  .onUpdate((change, context) => {
    ...
});

Note the missing '} at the end of the document reference.

This caused the deploy to fail with the following on the client

Failed to configure trigger provider

And with the following in the function logs

"status":{
  "code":13,
  "message":"INTERNAL"
},

Upvotes: 1

Ronnie Smith
Ronnie Smith

Reputation: 18595

Set up Node.js and the Firebase CLI

In many cases, new features and bug fixes are available only with the latest version of the Firebase CLI and the firebase-functions SDK. It's a good practice to frequently update both the Firebase CLI and the SDK with these commands inside the functions folder of your Firebase project:

npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools

Upvotes: 0

Kristopher Chayadi
Kristopher Chayadi

Reputation: 71

So right now I can deploy the function by changing the directory

'messages/{groupChatId}/{groupChatId}/{messageFeedItem}'

into

'messages/{groupChatId}/{groupChatId2}/{messageFeedItem}'

my speculation is you can't have same name to the wildcard

Upvotes: 4

aldobaie
aldobaie

Reputation: 1407

You have to import firebase functions

import functions = require('firebase-functions');

or

const functions = require('firebase-functions');

If you did, then check your package.json

Upvotes: 1

Related Questions