异步 https firebase 函数 [英] Asynchronous https firebase functions

查看:14
本文介绍了异步 https firebase 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTPS 函数是否应该像实时函数一样返回异步承诺?我们没有返回 HTTPS 函数(仅使用 res.status.send 等),而且看起来 firebase/function-samples 也不是.但是文档有点模棱两可 https://firebase.google.com/docs/functions/终止函数 .

Should HTTPS functions return asynchronous promises like realtime functions have to? We haven't been returning in HTTPS functions (just using res.status.send etc), and it looks like firebase/function-samples aren't either. But the documentation is slightly ambiguous https://firebase.google.com/docs/functions/terminate-functions .

推荐答案

HTTP 函数目前不遵守返回的承诺 - 它们需要发送结果才能正常终止.如果 HTTP 函数不发送结果,它将超时.

HTTP functions currently do not respect returned promises - they require a sent result in order to terminate normally. If an HTTP function doesn't send a result, it will time out.

所有其他类型的函数都需要返回一个 Promise 才能等待异步工作完全完成.

All other types of functions require a returned promise in order to wait for asynchronous work to fully complete.

如果您没有任何异步工作要等待,您可以立即返回.

If you don't have any async work to wait for, you can just return immediately.

这些是文档中概述的三种情况.

These are the three cases outlined in the docs.

这篇关于异步 https firebase 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆