简体   繁体   中英

How does Firebase update one callable function when you modify a code used by many other functions

I find myself in this situation way too often, and I can't find a clear explanation as to what is the right way to go.

Say you have (n) callable functions, (m) triggers, that all use an internal piece of code that you update. Should you deploy all functions that use that code, or updating one of them will propagate to the others?

PS: When I deploy the whole project, it usually fails. So now I only deploy functions individually which seems to work better. But deploying functions one by one is very tedious. Even when I deploy a list of functions it fails ie: firebase deploy --only functions:function1,function2

Unfamiliar with the answer to your question, I ran a quick test in typescript.

exports.testing1 = functions.https.onCall(test1);
exports.testing2 = functions.https.onCall(test2);

export async function getString(): Promise<(String)>{
    return("Hello test");
    //return "Hello World";
}
export async function test1(){
    //console.log("New test1");
    console.log(await getString());
}
export async function test2(){
    console.log(await getString());
}

I added these functions, then switched out the return hello test for hello world in the helper function, and added in the commented out New test 1 print. Then I ran

firebase deploy --only functions:testing1

Then called both functions again. testing1 updated to the new output, testing2 did not.

I appears that each functions compile completely, and run in their own runtime environment, which makes sense for stability and scalability purposes. Therefore, we can conclude updating a helper function and then not updating the entire project could cause some functions to use the old helper function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM