To investigate further, I checked the logs in Google Cloud, where I found this specific error:
PayloadTooLargeError: request entity too large
at readStream (/usr/lib/app/node_modules/raw-body/index.js:156:17)
...
The data I’m sending is around 250 KB in total, with individual fields that might contain objects up to 150 KB. These sizes seem relatively small, and I wouldn’t expect them to exceed any reasonable limits. I find it unusual to encounter this error, as both Wix and Google Cloud Run should be able to handle payloads of this size comfortably.
Could anyone clarify what might be causing this issue? Are there specific configuration steps I need to take in Wix or Google Cloud to increase the request size limit? Any guidance on debugging or resolving this would be greatly appreciated.
The error you’re encountering, PayloadTooLargeError, indicates that the server or middleware processing your request is rejecting it due to exceeding a defined payload size limit. Here’s how to address the issue for both Wix and Google Cloud SQL (PostgreSQL):
Step 1: Check Wix Backend Code
In Wix, the payload size limit may be related to the HTTP request handling in the backend code. By default, Wix may use certain libraries (like fetch) that don’t explicitly set payload size limits but can fail if the server rejects large payloads. Ensure the following:
Compress Your Payload: Reduce the size of your payload by compressing it, such as using gzip or JSON.stringify with optimization.
Stream Data: If possible, divide large payloads into smaller chunks and process them incrementally.
Log the Actual Payload Size: Add logging to track how large the payload is before sending the request:
By default, Google Cloud Run has a maximum HTTP request payload size limit of 32 MB, so your payload of ~250 KB should not trigger the error. However, middleware or other configurations may set lower limits.
Check Middleware in Your Cloud Run Service:
If you’re using libraries like express to handle incoming requests, ensure the payload limit is properly configured.
The error is explicitly from the raw-body package used internally for handling request bodies. Update the configuration for this package in your server code: