firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.02k stars 201 forks source link

Function execution took 58984 ms, finished with status: 'timeout' #1528

Closed sewellstephens closed 7 months ago

sewellstephens commented 7 months ago

Related issues

[REQUIRED] Version info

node: 18

firebase-functions: 4.5.0

firebase-tools:

firebase-admin: 11.0.0

[REQUIRED] Test case

const admin = require("firebase-admin");
const axios = require("axios");
const cors = require("cors");

admin.initializeApp();

exports.listSlackChannels1 = functions
  .region("us-central1")
  .runWith({
    minInstances: 0,
    maxInstances: 60,
  })
  .https.onRequest((req, res) => {
  cors(req, res, async () => {

    var db = admin.firestore();   

    res.setHeaders("Access-Control-Allow-Origin", "https://app.obeatow.com");
    res.setHeaders("Access-Control-Allow-Methods", "GET");

    db.collection("slackaccess").where("csite", "==", req.query.site).limit(1).get().then(snapshot => {

        snapshot.forEach(doc => {

        const options = {
            url: "https://slack.com/api/conversations.list",
            method: "GET",
            headers: {
              "accept": "application/json",
              "Authorization": `Bearer ${doc.data().token}`
            }
          };

          axios(options).then(response => {
           return res.status(200).send(response.data);
          })
          .catch(error => {
            return res.status(400).send(error);
          });
        });

    }).catch(error => {
        return res.status(400).send(error);
    })
  });
  });

[REQUIRED] Steps to reproduce

Run code and call function in backend

[REQUIRED] Expected behavior

The expected behavior is to return status code 200 along with Axios response received from Slack API call

[REQUIRED] Actual behavior

{
insertId: "18ylkiaeb4z3m"
labels: {2}
logName: "projects/rototer/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
receiveTimestamp: "2024-02-21T01:27:22.726216253Z"
resource: {2}
severity: "DEBUG"
textPayload: "Function execution took 60000 ms, finished with status: 'timeout'"
timestamp: "2024-02-21T01:27:22.715799216Z"
trace: "projects/rototer/traces/c3e4e9672800465f5b19dfbba400c36d"
}

Were you able to successfully deploy your functions?

yes I was

google-oss-bot commented 7 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

sewellstephens commented 7 months ago

seems to work when i removed res.setHeader