Skip to content

Cloud Function V2 randomly not creating deterministic Function URL #1447

@akb5566

Description

@akb5566

Related issues

  • None I could find.

[REQUIRED] Version info

node:

  • Node v19.5.0

firebase-functions:

  • firebase-functions 4.4.1

firebase-tools:

  • firebase-tools: 12.4.4

firebase-admin:

  • 11.10.1

[REQUIRED] Test case

Cloud Function

exports.updateChatroomEpoch = onCall(async (request) => {
    return 'hello';
});

Client Side

import { cloudFunc } from '$lib/firebase/firebaseConfig';
import { httpsCallable } from 'firebase/functions';
httpsCallable(cloudFunc, myFuncName).then((res) => {
    console.log('ya')
})

[REQUIRED] Steps to reproduce

  • Use firebase deploy --only functions to deploy the Cloud Function.

[REQUIRED] Expected behavior

According to https://cloud.google.com/functions/docs/calling/http#url, Cloud Function 2nd Gen should generate 2 Function URL:

  • https://REGION-PROJECT_ID.cloudfunctions.net/FUNCTION_NAME
  • https://FUNCTION_NAME-RANDOM_HASH-REGION.a.run.app

The cloudfunctions.net one has a deterministic format, while the latter one does not (including random hash).

[REQUIRED] Actual behavior

Some of my functions only generate the a.run.app one, not the cloudfunctions.net one.

a1 a2

In GCP Cloud Function Console, click on the cloudfunctions.net endpoint (the red arrows), it shows "Page not found".

However, if I navigate to GCP Cloud Run Console(the green arrows), it did successfully created an a.run.app endpoint(the orange arrow).

a3 a4

The cloudfunctions.net endpoint was somehow not created. This makes the httpsCallable from the client side always fail (the client would receive a CORS Error), because the httpsCallable is trying to access a url that does not exist.

Other information

This seems to happen randomly. I have deployed 68 functions at the same time, but only 2 of them have this problem.

a5

The solution is to delete the specific functions and deploy them again. And hope that they will create the endpoint this time. (At least it worked for me).

You HAVE TO delete the function, not just redeploy. Redeploy does not solve this problem.

I think this need to be investigated because it is clear that something went wrong when "deploying", but there are no errors from the firebase-tools. All the developer can see is the CORS Error in the browser, which can mean anything from incorrect region to not having permissions. But all they really need to do in this case is to delete the functions and deploy them again.

Were you able to successfully deploy your functions?

There were not error messages running firebase deploy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions