Closed sewellstephens closed 7 months ago
node: 18
firebase-functions: 4.5.0
firebase-tools:
firebase-admin: 11.0.0
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); }) }); });
Run code and call function in backend
The expected behavior is to return status code 200 along with Axios response received from Slack API call
{ 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" }
yes I was
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
seems to work when i removed res.setHeader
Related issues
[REQUIRED] Version info
node: 18
firebase-functions: 4.5.0
firebase-tools:
firebase-admin: 11.0.0
[REQUIRED] Test case
[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
Were you able to successfully deploy your functions?
yes I was