Firebase-functions: Deploying to specific function says successful, but files not updated

Created on 27 Aug 2018  路  12Comments  路  Source: firebase/firebase-functions

Version info

firebase-functions:
2.0.5

firebase-tools:
4.2.0

firebase-admin:
6.0.0

Test case

I've been using firebase to deploy my cloud function using the command:
firebase deploy --only functions

and it's been working great so far. However, I added a new cloud function under the same Google project. Now, I need to deploy only to specific functions, so I use the command:
firebase deploy --only functions:nameOfFunction

The cmd prompt says deployment was complete, but when I manually check the files in the function, they are not updated.

Steps to reproduce

Created a new cloud function under an existing Google project. Used the command:
firebase deploy --only functions:nameOfFunction

Function is not updated, although the cmd prompt says the deployment was successfully complete.

Were you able to successfully deploy your functions?

Yes, no error messages

Expected behavior

Function to be upated

Actual behavior

Function is not updated

deploy

Most helpful comment

I would like to add that I had the same problem, and just as I was about to post here, I realized the problem was the result of strange typescript build behavior, and not a server issue.

In summary, typescript is building into lib/functions/index.js instead of lib/index.js, thus package.json is pointing to the wrong file, and deploying an older compiled .js file.

I resolved it by (in my functions folder):

  1. deleting /lib/
  2. moving my types.ts to the root, along side all my other ts files. I do not use the src/ folder structure recommended by the official firebase docs. Having types.ts in a parent project folder was causing the compile to include these folders and further nest the compiled files inside of /lib/.
  3. editing functions/package.json -- "main": "lib/functions/index.js".

Here is a discussion on this exact issue: https://github.com/firebase/firebase-tools/issues/683

All 12 comments

Hi we have a known error where deployment prematurely reports success and the new function is actually only served 30 seconds later. So if you checked the functions after 1 minute, it should be the latest. Please let me know if this is not the case.

And if its not updated after 15 mins then what ?

I currently do a loop of 20 updates each time out of desperation - please fix it .....

I am having this issue as well and having to deploy multiple times to make sure it "sticks"

Hi @psimondk and @bungeye,

Can you provide more information on your issue? What are the steps you're doing, sample code you're trying to deploy? Thanks.

OK. New basic function. Had a typo in it the first time, so failed with an error. Fixed the typo and redeployed using:
firebase deploy --only functions:deleteAgency => get a successful deploy message

Run the function again, same error as previous as updated function not run, previously deployed code was run. Deploy a couple more times and updated function is eventually "active".
Sorry if that is a bit vague.

```exports.deleteAgency = functions.database.ref('/agencyMasters/{agencyRefKey}/deleteAgency')
.onWrite((change, context) => {
/* Grab the current value of what was written to the Realtime Database. */
const doDelete = change.after.val();
const agencyRefKey = context.params.agencyRefKey;
console.log("doDelete is: ", doDelete);
console.log("agencyRefKey is: ", agencyRefKey);

    if (!doDelete) {
        return null
    }
    /* fires function to delete agency in firebase and other actions */
    if (doDelete) {
        nukeAgency(agencyRefKey);
        return null
    };
    return null
});

```

go to the google cloud functions console (not firestore console) and delete it from there, i had the same problem, functions do not get deleted even though it says it did successfully.

@AndrewProteo the delete issue should be fixed with https://github.com/firebase/firebase-tools/issues/982.

If possible, can you share your firebase-debug.log?

@kevinajian been off for a bit will give it a bash with the --force option and report back. i assume based on the firebase/firebase-tools#982. the --force option is the way to do it?

@AndrewProteo the --force option is no longer needed with https://github.com/firebase/firebase-tools/pull/1007. Just make sure you've updated and deletes should work.

Closing due to inactivity.

I would like to add that I had the same problem, and just as I was about to post here, I realized the problem was the result of strange typescript build behavior, and not a server issue.

In summary, typescript is building into lib/functions/index.js instead of lib/index.js, thus package.json is pointing to the wrong file, and deploying an older compiled .js file.

I resolved it by (in my functions folder):

  1. deleting /lib/
  2. moving my types.ts to the root, along side all my other ts files. I do not use the src/ folder structure recommended by the official firebase docs. Having types.ts in a parent project folder was causing the compile to include these folders and further nest the compiled files inside of /lib/.
  3. editing functions/package.json -- "main": "lib/functions/index.js".

Here is a discussion on this exact issue: https://github.com/firebase/firebase-tools/issues/683

Hi we have a known error where deployment prematurely reports success and the new function is actually only served 30 seconds later. So if you checked the functions after 1 minute, it should be the latest. Please let me know if this is not the case.
I have same problem,after 1 minute my function not deploy in firebase

Was this page helpful?
0 / 5 - 0 ratings