Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deploy v2 function with uppercase letter in function name #57

Open
orbitcm-marcusrogers opened this issue Jun 15, 2023 · 7 comments

Comments

@orbitcm-marcusrogers
Copy link

I'm working to update my functions to v2. I'm running into an issue with deploying v2 functions that have an uppercase letter in the function name. V1 functions with an uppercase letter in the function name deploy fine. V2 Functions with names that are all lowercase deploy fine. I know firebase-tools just released an update to support uppercase letters in v2 function names - I'm using that version.

The error I get is "Function 'myFunction' is not defined in the provided module."

If I don't use this package, I'm able to deploy a v2 function defined as:

exports.myFunction = onCall(() => { return true; })

...so it seems there's no issue on the Firebase side with v2 functions with uppercase letters in the function name.

Functions all work fine in the emulator (including v2 functions with an uppercase letter in the function name).

Anyone been able to deploy v2 functions with an uppercase letter in the function name using this package?

@djiworks
Copy link

djiworks commented Jun 22, 2023

Hi, it's not working at all for me. Neither emulator or deploy finds functions even if all is in lowercase
I'm using node 18 as engine in package.json and "better-firebase-functions": "^6.0.0"

However, it works well when using exports.myFunction = onCall(() => { return true; })

// index.ts

import {exportFunctions} from "better-firebase-functions";
exportFunctions({__filename, exports});
// search.ts || callable/search.ts || callable/anything/search.ts
// Same for searchSomething.ts

import {HttpsError, CallableRequest, onCall} from "firebase-functions/v2/https";

export default onCall(
  {region: "europe-west1", maxInstances: 10},
  async ({data, auth}: CallableRequest ) => {
    if (!auth) {
      throw new HttpsError(
        "failed-precondition",
        "The function must be called while authenticated."
      );
    }
    console.log(data);
    return [];
  }
);
npm run shell
> ...
⚠  functions: Functions Emulator unable to start on port 5000, starting on 5001 instead.
✔  functions: Using node@18 from host.
i  functions: Loaded functions: 
No functions emulated.

@BenJackGill
Copy link

BenJackGill commented Jul 13, 2023

Did you get this working?

I also can't export anything at all.

The docs are a little contradictory...

In the Installation section is says we can name files like this src/auth/on-create.ts.

But then in the exportFunctions() Usage section it shows that we need to use the suffix .func.ts on files like ./http/new-user.func.ts. I assume that is so it know which files to use during the build process.

I have tried both variations and neither worked for me.

@BenJackGill
Copy link

Actually I think this might be more related to this issue where nothing is deployed when using Firebase-functions v4.

@george43g
Copy link
Owner

Hi everyone, will investigate the issue. I use my own lib in my own projects so I'm usually aware of any issues or breaking changes - seems a few people are having issues with it. I have not had any of these issues in v4, I suspect it's related to how the code is transpiled before deployment.

@cgossain
Copy link

cgossain commented Oct 1, 2023

I'm also having an issue with this. I updated from ^4.0.0 to ^ 6.0.0 and now all my function got deleted (tested in staging environment). It's not detecting my functions after updating.

Additionally, it was failing for 2nd Gen functions.

george43g added a commit that referenced this issue May 8, 2024
@george43g
Copy link
Owner

hey guys, just published version 6.0.1. Community has indicated that this should fix deploy issues people were having - give it a go and let me know if this fixes the issue. Such a regression is unfortunate and frustrating.

I have been thinking about having a dedicated firebase project to enable live testing of this package before every deployment, as this would catch these kinds of errors. However, this may be overkill. Given that all the deps are rolled up into a single dependency it surprises me that dep versions could cause an issue like this.

@orbitcm-marcusrogers
Copy link
Author

Hi @george43g , thanks for the release! Hopefully this solved some of the other problems mentioned in this Issue, but unfortunately I'm still unable to deploy functions with an uppercase character.

I looked at the output when I run exportFunctions and there seems to be a difference between functions with an uppercase character and those without:

  foldername: {
    filename: [Function],
    fileName: [Function (anonymous)] { __endpoint: [Object] }
  },

Every function (like foldername.filename above) that is all lowercase has a value that is just the function. Once you add an uppercase character, the value is what you see in foldername.fileName above. I observed this when there is an uppercase character anywhere in the name of the function (i.e. folderName.filename would give the same output as foldername.fileName).

I took a look through your code and didn't see anything obvious that would cause this difference, but maybe you'll spot it since you're more familiar with it than I.

Thanks again for the package and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants