Home > front end >  Firebase CLI is ignoring my cloud function when deploying
Firebase CLI is ignoring my cloud function when deploying

Time:11-06

I have cloud function defined in my index.ts. However, when try to deploy my cloud functions with firebase deploy, the Firebase CLI is not detecting my function.

Output in the terminal

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled
i  functions: preparing codebase default for deployment
i  functions: preparing cloud_functions directory for uploading...
i  functions: packaged /Users/nils/cloud_functions (243.98 KB) for uploading
✔  functions: cloud_functions folder uploaded successfully
i  functions: cleaning up build files...

✔  Deploy complete!

My index.ts

import { submitFunction } from "./features/submit/submit_function";

My submit_function.ts:

exports.submit = submitFunction();
import * as functions from "firebase-functions";

export async function submitFunction() {
  return functions.https.onRequest(async (req, response) => {
    response.status(200);
  });
}

CodePudding user response:

The Firebase CLI only looks at top-level exported functions, and the only top-level in your index.js file function does not match the signature of any Cloud Functions trigger.

Are you looking for this?

exports.submitFunction = functions.https.onRequest(async (req, response) => {
  response.status(200);
});

CodePudding user response:

The problem is that the submitFunction function is async.

Change your submitFunction from

export async function submitFunction() {
  return functions.https.onRequest(async (req, response) => {
    response.status(200);
  });
}

to

export function submitFunction() {
  return functions.https.onRequest(async (req, response) => {
    response.status(200);
  });
}
  • Related