firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

Firestore add method throws "Error: 13 INTERNAL: An internal error occurred."

Open dat-huynhtuan-tpv-clv opened this issue 1 year ago • 2 comments

[REQUIRED] Version info

"engines": {
    "node": "20"
  },
  "dependencies": {
    "axios": "^1.6.5",
    "firebase-functions-test": "^3.1.0",
    "cors": "^2.8.5",
    "firebase": "^10.7.2",
    "firebase-admin": "^11.11.1",
    "firebase-functions": "^4.6.0",
    "googleapis": "^131.0.0",
    "nodemailer": "^6.9.8",
    "eslint": "^8.56.0",
    "eslint-plugin-promise": "^6.1.1"
  }

node: 18.16.1

firebase-functions: 4.6.0

firebase-tools: 13.11.2

firebase-admin: 11.11.1

[REQUIRED] Test case

const { onObjectFinalized } = require('firebase-functions/v2/storage');
const admin = require("firebase-admin");
const { Storage } = require('@google-cloud/storage');
const storage = new Storage({
    projectId: projectId,
    keyFilename: keyFileName
});
admin.initializeApp();

exports.storageInsertEvent = onObjectFinalized({
    bucket: BUCKET[0],
    memory: '1GiB',
    timeoutSeconds: 120
}, async event => {
   try {
        ......
        await admin.firestore().collection(myCollection).add(insertFSObject).then(() => {
            console.log(`FIRESTORE - Object ID: ${event.data.name}`, "[INSERT COMPLETED]");
        }).catch((error) => {
            // console.log(`PATH FILE: ${event.data.name}`, "FIREBASE ERROR");
            console.log(`FIRESTORE - FileName: ${event.data.name}`, "[INSERT FAILURE]");
            console.log(error);
        });
    } catch (error) {
        console.log("Code Error", "[CODE FAILURE]");
        console.log(error);
    }
});

I have checked my codes and logs within the Log Explorer of the current cloud function but before or after the error, the error is no where to be seen again. I also test this code at non-prod environment but also found no clue. This is my error message

Error: 13 INTERNAL: An internal error occurred.
    at callErrorFromStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:192:76)
    at Object.onReceiveStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
    at Object.onReceiveStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/resolving-call.js:94:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

[REQUIRED] Steps to reproduce

See my test case section

[REQUIRED] Expected behavior

The function should show success insert like all the logs before or after the error.

[REQUIRED] Actual behavior

Only one error is thrown out, I did check in my firesbase datastore, all the data before and after the error were successfully inserted only one record was not inserted

Were you able to successfully deploy your functions?

Yes. The function was deployed 2 weeks ago and it was doing fine until now

dat-huynhtuan-tpv-clv avatar Jun 30 '24 14:06 dat-huynhtuan-tpv-clv