Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase emulator for Cloud Functions not updating the code

I'm deploying the following cloud function using firebase deploy --only functions :

export const testFunction = functions.https.onCall((data, context) => {
  return {"data": "hello"};
});

and when call it from the client app using the code

var testFunction = firebase.functions().httpsCallable("testFunction");
      testFunction().then((result) => {
        // Read result of the Cloud Function.
        this.data = result.data;
});

it works as expected. Now, I want to continue developing the function testing it on the local emulator so, following the documentation, I added this line to the web app code (before the function)

firebase.functions().useEmulator("localhost", 5001); // for local simulator

and I run the local emulator with:

firebase emulators:start --only functions

If I run the client app now, I correctly see the call going through the local emulator instead of the remote cloud function.

Problem: If modify the code the local function doesn't get updated. I need to run firebase deploy again in order to see the change in the response. How can I just deploy locally?

like image 631
Claus Avatar asked Feb 05 '26 14:02

Claus


1 Answers

This stackoverflow solves the issue.

Solution in short:

  • After every change in your code, run npm run build to recomplie the code.

  • To auto-compile for every change in your code. Change "build": "tsc" to "build": "tsc -w" in your package.json file, and run the emulator in an another terminal window.

like image 107
Praveen Avatar answered Feb 09 '26 07:02

Praveen