Skip to content

Cloud Function V2 randomly not creating deterministic Function URL #1447

Closed

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.

Activity

  1. google-oss-bot commented on Jul 18, 2023

    @google-oss-bot
    Collaborator

    I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

  2. Berlioz commented on Jul 20, 2023

    @Berlioz
    Contributor

    So I'm really sorry to say this given that you've put a lot of work into this Github issue, but I think you'd have a lot more luck with Firebase Support (https://firebase.google.com/support/troubleshooter/contact) --this seriously looks like an issue with the integration with Google Cloud Functions. Debugging this is likely going to involve looking at deploy-specific logs and that means identifying your cloud project and peeking at its contents. We can't do that off of a Github issue, but we can with a contact made through support.

  3. JJ11teen commented on Jul 23, 2023

    @JJ11teen

    I am experiencing the same issue.

    I understand that a support ticket is better for specific cases, but thought it was worth capturing that this is happening to multiple users here as well.

  4. JJ11teen commented on Jul 23, 2023

    @JJ11teen

    Also massive thanks to @akb5566 for the write up and workaround! (:

  5. LogansUA commented on Oct 5, 2023

    @LogansUA

    Yep, so same thing for me. Deleting and re-deploy function through GCP Console -> Cloud Functions worked, thank you @akb5566
    Also, this thread might answer some of the questions regarding functions URL

  6. thandal commented on Sep 19, 2024

    @thandal

    Same thing happened to me today.
    [edited]
    ... had to delete/deploy three times. Finally, the firebase console still showed the cryptic URL, but the Cloud Run function dashboard showed the cloudfunctions.net one, and requests started working with that one.

  7. dfrancisc commented on May 26, 2025

    @dfrancisc

    Not really sure if this helps somebody but after spending two days on this I found out that:

    1. remove firebase-functions-test dependency
    2. Clean and reinstall all dependencies after making a change
    3. rebuild and deploy
    4. works

    This is the only way I got it working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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