Skip to content

Callable functions not found when testing on Emulator #1627

@PabloMzGa

Description

@PabloMzGa

Related issues

I haven't found any related issues.

[REQUIRED] Version info

Node version: v18.19.1

firebase-functions: 6.0.1

firebase-tools: 13.22.0

firebase-admin: 12.1.0

[REQUIRED] Test case

I am using a test code based on the docs. I have tested with the quickstart repo getting the same results: Link.

Here is my code:

index.ts (inside the "functions" folder)

import { onCall } from "firebase-functions/v2/https";
exports.test = onCall((request) => {
    console.log("Recibida llamada");
    return { message: "Hello from Firebase!" };
  });`

test.ts (outside of functions folder)

import { initializeApp } from "firebase/app";
import { getFunctions, httpsCallable, connectFunctionsEmulator } from "firebase/functions";

// Firease config
const firebaseConfig = {
  projectId: "demo-project",
  storageBucket: "demo-project.appspot.com",
  messagingSenderId: "123456789",
  appId: "1:123456789:web:abcdef",
};

// Firebase init
const app = initializeApp(firebaseConfig);

// Get functions ref
const functions = getFunctions(app);

// Connect with emulator
connectFunctionsEmulator(functions, "127.0.0.1", 5001);

// Call function
const myFunction = httpsCallable(functions, 'test');

myFunction({ some: 'data' })
  .then((result) => {
    console.log(result.data);
  })
  .catch((error) => {
    console.error("Error calling function:", error);
  });

[REQUIRED] Steps to reproduce

  • Set up functions project
  • Import code
  • Install dependencies and set up emulator with "firebase emulators:start --project demo-test"
  • Execute "test.js"

[REQUIRED] Expected behavior

It should connect with the emulator and return the promise from the function and execute it correctly.

[REQUIRED] Actual behavior

I get an error with the promise. This is my console log:

Error calling function: [FirebaseError: not-found] { code: 'functions/not-found', customData: undefined, details: undefined }

I know it's connecting to the emulator because when I change the port or the ip, i get internal-error instead. Also the deployment on the emulator it's correct because it appears on the log. It works correctly when called from firebase functions:shell.

Were you able to successfully deploy your functions?

I am not testing deployment since I need this just for testing.

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