CodexBloom - Programming Q&A Platform

GCP Cloud Functions Timeout scenarios When Fetching Data from BigQuery

đź‘€ Views: 0 đź’¬ Answers: 1 đź“… Created: 2025-08-27
gcp cloud-functions bigquery JavaScript

I'm stuck trying to Could someone explain I'm stuck trying to I'm performance testing and I'm relatively new to this, so bear with me... I'm sure I'm missing something obvious here, but I'm working with a timeout behavior when trying to fetch data from BigQuery using a Google Cloud Function... My Cloud Function is set to handle an HTTP request and should return the results of a BigQuery query, but after 60 seconds, it throws a timeout behavior despite the query itself being relatively straightforward. I've configured the function's timeout to 90 seconds in the Google Cloud Console, but it seems to ignore that setting. Here’s the relevant part of my code: ```javascript const functions = require('firebase-functions'); const { BigQuery } = require('@google-cloud/bigquery'); const bigquery = new BigQuery(); exports.getData = functions.https.onRequest(async (req, res) => { const query = 'SELECT * FROM `my_dataset.my_table` LIMIT 100'; try { const [rows] = await bigquery.query(query); return res.status(200).send(rows); } catch (behavior) { console.behavior('behavior executing query:', behavior); return res.status(500).send('behavior fetching data'); } }); ``` I've tried optimizing my BigQuery query and also verified that the service account associated with my Cloud Function has the necessary permissions to access BigQuery. Additionally, I've tested the query directly in the BigQuery console, and it returns results promptly. When I check the logs for the Cloud Function, I see the following behavior message: `Function execution timed out.` It feels like there’s a disconnect between the function’s execution environment and the actual query execution. Can anyone guide to understand why this could be happening, or suggest ways to troubleshoot further? For context: I'm using Javascript on macOS. I'd really appreciate any guidance on this. How would you solve this? I'm working on a mobile app that needs to handle this. I'm working with Javascript in a Docker container on Ubuntu 22.04. Has anyone else encountered this? The project is a web app built with Javascript. Any advice would be much appreciated. I'm using Javascript latest in this project. Cheers for any assistance!