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.
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.
Is there a way to make GCF to flush on each 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.
See also:
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.