Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
How to compress json response size in Firebase cloud functions?

i have a firebase callable function that takes data from a sql cloud database (mysql).

this is the code:

// Get records
exports.getRecords = functions.region("europe-west1").https.onCall((data, context) => {
  // get data
  const table_name = data.table_name

  return mysqlPromise.createPool(db.connectionOptions)
    .then(pool => {    
      return pool.query(`
        SELECT * FROM ${table_name};`
      )
    })
    .then(res => {
      return { result: res };
    })
    .catch(error => {
      throw new functions.https.HttpsError('failed-precondition', error);
    });
});

If I run the function on a table with few rows (up to 10000) it works perfectly, but if the table is bigger (100K records) the execution fails showing a "CORS error".

Analyzing the response, I noticed that the response size on a query that requires 100K rows is around 25MB.

I know that the limit quota of the firebase functions is 10MB for each response, and I am pretty sure that the error is due to that (even if CORS sounds strange).

The question is:

"Is there any way to run that query that returns a 100k rows json to me?"

maybe I have to compress the response or else ... what is the best solution?

Thanks in advance! :)

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!