stripe-firebase-extensions icon indicating copy to clipboard operation
stripe-firebase-extensions copied to clipboard

Rate Limit on large invoices

Open TheRealFlyingCoder opened this issue 2 years ago • 0 comments

Bug report

  • Extension name: firestore-stripe-invoices

Describe the bug

Due to the extension making a request for each line item on an invoice, I am hitting the rate limit when multiple invoices are triggered at the same time:

ext-firestore-stripe-invoices-sendInvoice
      'Request rate limit exceeded. You can learn more about rate limits here https://stripe.com/docs/rate-limits.', 

Stripe invoices can have up to 250 line items, and this specific scenario was a single invoice with >100 line items.

Expected behavior

Due to this being a cloud function, triggered by a document creation, it is not inherently time sensitive.

With a default function time-out of 5min and a maximum of ~250 requests, SendInvoices function could easily send each request on an interval of 1 second for the least impact, allowing 100 asynchronous invoice triggers to run side by side.

Preferably a single request to create the invoice would allow the solution to scale better, i'm not sure why it doesn't?

TheRealFlyingCoder avatar Nov 03 '21 23:11 TheRealFlyingCoder