Quota exceeded when updating users with Firebase Admin SDK - how can I request more?

核能气质少年 提交于 2020-01-23 07:04:49

问题


We try to update many users in our multitenant setup, when a whole tenant needs to be enabled/disabled. With this, we sometimes run into QUOTA_EXCEEDED errors, especially for large tenants with many users. I have asked how to do this better here: Disable many users at once

As there are currently no bulk operations to update users with the Firebase Admin SDK, how can I request a quota raise?

  • I do not see an enable/disable users in the Firebase Authentication Limits

  • The error message does not indicate what has to be changed. It only says

    Exceeded quota for updating account information.

  • I do not see any limit reached on the quotas page for the project (https://console.cloud.google.com/iam-admin/quotas).

How can I raise the quota?


回答1:


firebaser here

If you're running into quota limits that can't be changed from the Firebase console, reach out to Firebase support for personalized help. They can typically help raise quota temporarily, and it's also a great indicator for our engineering team on the need for a feature.




回答2:


For everybody having the same issue, here is a solution.

I contacted firebase support and got this answer

If you try to update a user’s information at once (more than 10 users or requests per second), then you'll be encountering this error message "Exceeded quota for updating account information". Please note that when we get a huge amount of requests in a short period of time, throttling is applied automatically to protect our servers. You may try sending the requests sequentially (distribute the load) instead of sending them in parallel. So basically, you'll need to process them one at a time (instead of all at once) in order to avoid the error.

So i solved this with a timeout that sends an individual record every 100ms

function listAllUsers(nextPageToken) {
        let timeout = 0;
        admin.auth().listUsers(1000, nextPageToken)
            .then(function (listUsersResult) {
                listUsersResult.users.forEach(function (userRecord) {
                    timeout = timeout + 100
                    nextUser(userRecord.uid, timeout)
                });
                if (listUsersResult.pageToken) {
                    listAllUsers(listUsersResult.pageToken);
                }
            })
            .catch(function (error) {
                console.log('Error listing users:', error);
            });
    }
    listAllUsers();

The nextUser function:

function nextUser(uid, timeout) { 
        setTimeout(() => {
            admin.auth().setCustomUserClaims(uid, { client: true }).then(() => {
            }).catch(function (error) {
                console.log('Error setting user:', error);
            });
        }, timeout);
    }


来源:https://stackoverflow.com/questions/52926113/quota-exceeded-when-updating-users-with-firebase-admin-sdk-how-can-i-request-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!