简体   繁体   English

当您修改许多其他函数使用的代码时,Firebase 如何更新一个可调用的 function

[英]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.我发现自己经常遇到这种情况,而且我找不到关于 go 的正确方法的明确解释。

Say you have (n) callable functions, (m) triggers, that all use an internal piece of code that you update.假设您有 (n) 个可调用函数,(m) 个触发器,它们都使用您更新的一段内部代码。 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. PS:当我部署整个项目时,它通常会失败。 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即使当我部署函数列表时它也会失败,即: firebase deploy --only functions:function1,function2

Unfamiliar with the answer to your question, I ran a quick test in typescript.不熟悉你的问题的答案,我在 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.我添加了这些功能,然后在 helper function 中关闭了 hello world 的 return hello test,并在注释掉的 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. testing1更新到新的output,testing2没有。

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.因此,我们可以得出结论,更新 helper function 然后不更新整个项目可能会导致某些功能使用旧 helper function。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从本地主机调用 firebase 可调用函数? - how to call firebase callable functions from localhost? Firebase 可调用 Function + CORS - Firebase Callable Function + CORS 与 Firebase 函数一起使用时,Nodemailer 无法正常工作 - Nodemailer not working when used with Firebase Functions Firebase Cloud Functions - 从 https 中的上下文获取来源可调用 function - Firebase Cloud Functions - get origin from context in https callable function 从 Angular 调用 Firebase 可调用函数时出现 CORS 错误? - CORS error when calling Firebase Callable Functions from Angular? `httpsCallable` 与 `httpsCallableFromURL` 可调用 Firebase 函数 - `httpsCallable` vs. `httpsCallableFromURL` callable Firebase Functions 运行 Firebase Cloud Functions 时使用哪个服务帐户? - Which service account is used when running Firebase Cloud Functions? Function.database 和 Firebase.database 有什么区别? 什么时候使用一个而不是另一个? - What is the difference between Function.database and Firebase.database? When to use one over the other? Firebase 可调用 Function 返回空数据 - Firebase Callable Function returning nill data Firebase 函数部署问题(无法创建/更新函数) - Firebase functions deploy problem (Failed to create/update function)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM