I am getting this error when a cloud function is executed:
Error: TRIGGER_PAYLOAD_TOO_LARGE: This request would cause a function payload exceeding the maximum size allowed.
This is the cloud function causing the error:
exports.inyectSerie = functions.database.ref('forms/{pushId}').onCreate(event => {
if (!admin.apps.length) {
admin.initializeApp();
}
var form = event.val();
var formData = {
serie: form.serie
};
admin.database().ref('series/'+form.serie).set(formData);
});
How do I know this is the function causing the error? I removed all cloud functions from my firebase and it worked as expected. Then I put back this inyectSerie function and it gave me the error again.
This is my firebase structure, being "medidores" node the one with the most data, with 150k records (which doesn't sound like a lot to me):
+fallidas
+forms <-- This has only 20 records
+materiales
+medidores <-- This has 150,000+ records
+series
+users
If you notice, medidores node is never touched on the cloud function.
I searched for the error and only found this other question reporting it, but I think the cloud function causing the problem on that case did access all the records on the db.
The only thing that comes to my mind to be the problem on my case, is that functions.database loads the whole database no matter what.
UPDATE: Even after reducing my trigger to a bare minimum (thanks, James Poag), I am getting the same error.
exports.inyectSerie = functions.database.ref('forms/{pushId}').onCreate(event => {
return null;
});