Firebase cloud function local code changes are not reflected in emulators
See original GitHub issueI 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
- index.js code:
exports.test = functions.https.onRequest(async (request, response) => {
response.status(200).send("First");
});
- Successfully deployed the test method.
the command used to deploy:
firebase deploy --only functions:test
- In Postman made the following GET request.
https://us-central1-<project-name>.cloudfunctions.net/test
Result: First
Status: 200 OK
- Started the emulators:
firebase emulators:start --only functions
- 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.
- Changed the function code to:
exports.test = functions.https.onRequest(async (request, response) => {
response.status(200).send("Second");
});
- 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:
- Created 3 years ago
- Comments:11 (5 by maintainers)
@Abhimanyu14 glad it’s working!
Also you can use
tsc -w
to have TypeScript automatically rebuild every time you save.@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 inlib/index.js
(that’s what is defined inmain
inpackage.json
).So I suspect you’re just forgetting to compile after changing the TS source.