简体   繁体   中英

Firebase Cloud Function finished with status: 'response error'

I have a cloud function that is returning a lot of data (50'000 documents) as objects. When I run it I get the error finished with status: 'response error' .

This only happens when I export all of the data, when a limit (up to 20'000) is applied it works without problem. This lets me think that the response might be too big, but there is no info in the logs about this at all. Also adding try / catch does not work. In the console I only get the above message without any further indication.

I know that functions normally log when timeout is hit or the memory exceeded, so I am wondering what else could be the source of error.

exports.run = functions.runWith({ timeoutSeconds: 540, memory: '8GB' }).https.onRequest(async (req, res) => {
  try {
    const querySnap = await db.collection("myData").get();
    const data = querySnap.docs.map(doc => doc.data());
    return res.status(200).json({
      data: data
    }).end();

  } catch (err) {
    console.log(err);
    return res.status(400).end();
  }
});

EDIT : It is indeed the size of the response that causes this error. You can reproduce this if you simply return data of given size (with Buffer.alloc(bytes) ).

I thins you hit the max HTTP response size which is 10 MB for HTTP functions

Reference: https://cloud.google.com/functions/quotas#resource_limits with the screenshot below take from that ref.

在此处输入图像描述

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