简体   繁体   English

使用 Google Cloud Functions 时刷新分块传输?

[英]Flushing chunked transfer when using Google Cloud Functions?

exports.cloudFunctionEntryPoint = async (req, res) => {
    setTimeout(()=>{
        res.write("1\n");
    }, 1000)
    setTimeout(()=>{
        res.write("2\n");
    }, 2000)
    setTimeout(()=>{
        res.write("3\n");
    }, 3000)
    setTimeout(()=>{
        res.write("4\n");
    }, 4000)
    setTimeout(()=>{
        res.write("5\n");
        res.end();
    }, 5000)
}

When using a local expressjs server, the server would flush immediately on each res.write , so I can get the numbers on every second.使用本地 expressjs 服务器时,服务器会在每次res.write时立即刷新,因此我可以每秒获取数字。

However on the GCF, data is flushed only when res.end() is called, so I can only get all numbers together at the 5th second.但是在 GCF 上,只有在res.end()时才会刷新数据,所以我只能在第 5 秒将所有数字放在一起。

Is there a way to make GCF to flush on each res.write ?有没有办法让 GCF 在每个res.write上刷新?

It's not possible.这是不可能的。 Cloud Functions buffers all of the output, up to a max 10MB, before it's sent to the client. Cloud Functions 在发送到客户端之前会缓冲所有 output,最大为 10MB。

See also:也可以看看:

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

相关问题 在 Async Google Cloud Functions 中使用“return” - Using "return" in Async Google Cloud Functions Google Cloud Platform 文件传输问题 - Google Cloud Platform File Transfer Issues Google Cloud Functions 标头响应 - Google Cloud Functions Headers response Python 和 HTTP Google Cloud Functions 上的“导入请求” - Python and "import requests" on HTTP Google Cloud Functions 有没有办法检测 Google Cloud Functions 中的冷启动? - Is there a way to detect cold start in Google Cloud Functions? 如何调试 Google Cloud Functions 中的 Axios 错误? - How to debug Axios Errors in Google Cloud Functions? 谷歌云功能 Firebase 使用 NodeJS 更新 FieldValue.increment(1) - TypeError: FieldValue.increment is not a function - Google cloud functions Firebase Update FieldValue.increment(1) using NodeJS - TypeError: FieldValue.increment is not a function 使用firebase云函数登录 - Sign In using firebase cloud functions 当我尝试初始化 firebase 应用程序时,为什么 Google Cloud Functions 会抛出“配置 firebase.databaseURL 的无效值”错误? - Why is Google Cloud Functions throwing a "Invalid value for config firebase.databaseURL" error when I try to initialize a firebase app? 使用 Google Kubernetes 引擎在本地运行项目时,VS Code 使用了错误的 Google Cloud 帐户 - VS Code using wrong Google Cloud account when running project locally with Google Kubernetes Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM