question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firebase cloud function local code changes are not reflected in emulators

See original GitHub issue

I have posted a question in StackOverflow. Creating a bug here as recommended by Doug Stevenson. StackOverflow Post link: https://stackoverflow.com/q/64845931/9636037

Issue details: I am trying to develop API for my apps using Firebase cloud functions. Following this (https://firebase.google.com/docs/emulator-suite) site to use the firebase emulator suite for development and testing locally.

Issue: The changes are not reflected in the locally emulated functions.

[REQUIRED] Environment info

firebase-tools: 8.16.2 Platform: Windows 10 Node: 10.15.3 (node --version)

[REQUIRED] Test case

[REQUIRED] Steps to reproduce

  1. index.js code:
exports.test = functions.https.onRequest(async (request, response) => {
   response.status(200).send("First");
});
  1. Successfully deployed the test method.

the command used to deploy:

firebase deploy --only functions:test
  1. In Postman made the following GET request.
https://us-central1-<project-name>.cloudfunctions.net/test
Result: First
Status: 200 OK
  1. Started the emulators:
firebase emulators:start --only functions
  1. In Postman made the following GET request.
http://localhost:5001/<project-name>/us-central1/indexTest
Result: First
Status: 200 OK

Same as the actual deployed function.

  1. Changed the function code to:
exports.test = functions.https.onRequest(async (request, response) => {
    response.status(200).send("Second");
});
  1. Getting the same result as before when hitting the emulated function in the localhost. The changes are not reflected.

Also, tried stopping the emulator and starting it again. No luck.

[REQUIRED] Expected behavior

Locally emulated functions in the emulator should reflect the local code changes.

[REQUIRED] Actual behavior

The emulator is not recognizing the local code changes.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
samtsterncommented, Nov 16, 2020

@Abhimanyu14 glad it’s working!

Also you can use tsc -w to have TypeScript automatically rebuild every time you save.

2reactions
samtsterncommented, Nov 16, 2020

@Abhimanyu14 after changing your TypeScript code you have to run npm run build to compile it again. The Functions emulator looks at the compiled code which is in lib/index.js (that’s what is defined in main in package.json).

So I suspect you’re just forgetting to compile after changing the TS source.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase cloud function local code changes are not reflected ...
Following this site to use the firebase emulator suite for development and testing locally. Issue: The changes are not reflected in the locally...
Read more >
Run functions locally | Cloud Functions for Firebase - Google
Run the emulator suite. Note: Code changes you make during an active session are automatically reloaded by the emulator. If your code needs...
Read more >
The Full Guide on how to use the Firebase Emulator for the Web
First, it will ask you to pick which emulators you want to use, in this guide, we'll cover Authentication, Firestore, and Cloud Functions,...
Read more >
Flutter Tutorial: How to use the Firebase Local Emulator with ...
Firebase Cloud Functions Setup. Before we can run any code, we need to create a local Firebase project. If you're not familiar with...
Read more >
Debugging Firebase Functions in VS Code - Medium
Here we are specifying the debug settings. The debugger should attach to port 9229 (default for firebase emulator) to debug the emulator we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found