Description
Which sample has a bug?
Sample name or URL where you found the bug
const {onCall, HttpsError} = require("firebase-functions/v2/https");
How to reproduce the issue
Not sure how this can be reproduced: previous versions of same code had been deployed and currently in production. This started randomly.
Tl:Dr:
- I have a few firebase functions (2nd generation) currently being tested in production
- I deployed several iterations of one of the functions already
- Then I refactored some code, tried re-deploying again, and suddenly,
onCall
imported fromfirebase-functions/v2/http
stopped working
Failing Function code used (if you modified the sample)
Current code in production (and working) has onCall
imported as a named import this way:
import {HttpsError, onCall} from "firebase-functions/v2/https"
After the deployment failure started, I fell back to using require
as shown in the example I posted above. i.e.
const {onCall, HttpsError} = require("firebase-functions/v2/https");
Basic structure of what I have in production:
import * as admin from "firebase-admin";
import {HttpsError, onCall} from "firebase-functions/v2/https"
import {CallableRequest} from "firebase-functions/lib/common/providers/https";
import {APIRequestPayload} from "./typeDef"; //some custom type definition
exports.myfunctionname = onCall({
enforceAppCheck: true,
secrets: ["A_SECRET_I_USE"],
region: "us-east1",
cpu: 2,
concurrency: 500,
maxInstances: 15,
}, async (incomingData: CallableRequest) => {
const data: APIRequestPayload = incomingData.data;
const secretVariable = process.env.A_SECRET_I_USE;
//
** some code logic
//
if(someError) {
throw new HttpsError("internal", "Something went wrong");
}
return {codeLogicResult: somecodeprocessingresult}
})
Steps to set up and reproduce
- Write a basic function
- Run
npm run deploy
from thefunction
folder
Debug output
Errors in the
console logs
Screenshots
Expected behavior
Function should be deployed when npm run deploy
is run from the cli as per documentation
Actual behavior
Function fails to deploy with the error message above