Demo, all content is generated
Question

Firebase callable function only returns 'internal' and nothing else

Solved · 421 views · asked by frankie_r · edited

Frontend calls httpsCallable(functions, "createInvite") and I get FirebaseError: internal. That's the whole error. How am I supposed to debug that?

What I’ve tried

Wrapped the call in try/catch and logged error.details, it's undefined. Bolt keeps adding console.logs to the frontend which doesn't help.

Comment
Check the function logs, the client never gets the real error. sven_fire · edited

3 answers

Marked as helpful by the asker
sven_fire · edited

"internal" is what the client sees when the function throws something that isn't an HttpsError. The real error is in the function logs: Firebase console → Functions → Logs, or firebase functions:log --only createInvite.

Once you find it, throw errors you want the client to see like this:

import { HttpsError } from "firebase-functions/v2/https";
throw new HttpsError("invalid-argument", "Email is missing");

Also make sure the region matches. If the function is deployed to europe-west1 and the client uses getFunctions(app) without a region, it calls us-central1 and you can get confusing errors. Use getFunctions(app, "europe-west1").

Comment
It was the region!! function in europe-west1, client calling us-central1. never would have found that frankie_r · edited
same region bug here, bookmarking tariq_builds · edited
lukas_b · edited

For next time: run the Functions emulator locally (firebase emulators:start --only functions,firestore). The real stack trace shows up in your terminal instead of "internal".

Comment
amara_v · edited

+1 on logs. Bolt can't see your Firebase logs so it just guesses. Copy the log line into the chat and it fixes it immediately.

Comment