Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase error: TOO_MANY_TRIGGERS

In our Firebase application there is a list with lots of items in Realtime Database. Every create, update and delete operation on single item is processed by Firebase Cloud Function with onWrite trigger (in simplest case this function just counts items). But sometimes there is a need for bulk operation on items without need for individual processing. Let's say we want in single transaction remove all items and reset counters.

Earlier it worked just fine. Due to the limit of 1000 for number of Cloud Functions triggered by a single write (https://firebase.google.com/docs/database/usage/limits), no functions where triggered at all and it was desired outcome.

Now, without any change to application code we have an error

Error: TOO_MANY_TRIGGERS: This request would cause too many functions to be triggered.

Same error appears in client application, Admin API and even when importing json using the web interface. Only option that works for us is processing of items in batches. But it is not transactional and takes up to tens of minutes instead of milliseconds as before.

What options do we have to bypass this error? Optimally this would be some switch to skip function triggering in case of exceeding the limit.

like image 839
Maksim Klimenko Avatar asked Jun 02 '18 17:06

Maksim Klimenko


People also ask

How many times can I deploy to Firebase?

So 12000/70 gives around 170 functions deploys per day. On Quotas admin page (second link) you can ask to increase any quota with Edit Quota option. 36000 sec build time is available without any additional approvals which in my case increased individual functions deploys number to 500+ per day.

Does firebase have a limit?

While not a hard limit, if you sustain more than 1,000 writes per second, your write activity may be rate-limited. 256 MB from the REST API; 16 MB from the SDKs. The total data in each write operation should be less than 256 MB. Multi-path updates are subject to the same size limitation.

Can firebase handle 10 million users?

The limit you're referring to is the limit for the number of concurrently connected users to Firebase Realtime Database on the free Spark plan. Once you upgrade to a payment plan, your project will allow 200,000 simultaneously connected users.

How many request can firebase handle?

10 for single-document requests and query requests. 20 for multi-document reads, transactions, and batched writes. The previous limit of 10 also applies to each operation.


3 Answers

For anybody reading this question post-2018, there is now an option to disable strict enforcement for trigger limits.

Strict validation is enabled by default for write operations that trigger events. Any write operations that trigger more than 1000 Cloud Functions or a single event greater than 1 MB in size will fail and return an error reporting the limit that was hit. This might mean that some Cloud Functions aren't triggered at all if they fail the pre-validation.

If you're performing a larger write operation (for example, deleting your entire database), you might want to disable this validation, as the errors themselves might block the operation.

To turn off strictTriggerValidation, follow these steps:

  • Get your Database secret from the Service accounts tab of your Project settings in the Firebase console.
  • Run the following CURL request from your command line:

    curl -X PUT -d "false" https://NAMESPACE.firebaseio.com/.settings/strictTriggerValidation/.json?auth\=SECRET

See here for the docs: https://firebase.google.com/docs/database/usage/limits

like image 66
Ryan Avatar answered Oct 22 '22 08:10

Ryan


There is currently no way to prevent triggers from running in special circumstances. The only way around this is to undeploy all your triggers, perform your updates, then deploy all your triggers again.

I would encourage you to file a feature request for this.

like image 6
Doug Stevenson Avatar answered Oct 22 '22 09:10

Doug Stevenson


I just got this error message in an older, Flutter project that I hadn't touched in quite some time.

[firebase_database/unknown] TOO_MANY_TRIGGERS: This request would cause too many functions to be triggered.

It turned out that here it was caused by the fact that my Cloud Functions were still set to use Node v8, which was retired in early 2021.

Upgrading the Cloud Functions to use Node v12 (no other changes needed) removed the error message for me.

like image 1
Frank van Puffelen Avatar answered Oct 22 '22 09:10

Frank van Puffelen