Summary

The dashboard couldn’t load user data for large datasets because AWS Lambda cannot return payloads over 6MB.

Also, since we’re using Node.js 22, the old aws-sdk (v2) is no longer bundled, so we had to switch to AWS SDK v3 (@aws-sdk/client-s3), which is already pre-installed in the Node.js 22 Lambda runtime.

The fix:

  1. Use AWS SDK v3 (pre-installed) instead of v2 (no extra installation needed).
  2. Compress MySQL results (gzip) before sending.
  3. Upload the compressed file to S3.
  4. Return a presigned URL for the client to fetch.
  5. Increase Lambda timeout to 30 seconds so large queries and compression can complete smoothly.

Step-by-Step Implementation Guide

Step 1. Create the S3 Bucket

  1. In AWS Console → S3 → Create bucket, name it:

    user-data-for-dashboard-bucket
    

    (Must match the name used in your Lambda code.)

  2. Select the same region as your Lambda.

  3. Leave Block Public Access enabled.