Solution: I mitigated these errors somewhat by using q.fetch_only()
Problem: I was storing large amount of data as Simple Objects in the database rows, and every time I queried the database it fetched these large Simple Objects (JSON). So it seems that the fix is to limit what is fetched from the db.
Read the docs here:
Hope this helps if anyone encounters similar errors.
P.S. I have accelerated tables enabled so it might be connected to the issue.
It would be nice to know what are the limits of Data payload, so that we could estimate if the size is too large. @meredydd
This was the answer in 2018, but I am unsure if it was increased since then:
So it seems like it is possible to store larger than 4MB objects in the database, constructed entirely from within server modules, however you will not be able to send them anywhere outside of the server module without converting them to a media object or doing some kind of processing to get smaller results.
(You can probably convert them to a json bytes string, attach it to a media object, and then send that, reconstructing it on the other side of the call)