Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe Wrapper Rate Limit? #234

Open
daveycodez opened this issue Jan 30, 2024 · 3 comments
Open

Stripe Wrapper Rate Limit? #234

daveycodez opened this issue Jan 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@daveycodez
Copy link

daveycodez commented Jan 30, 2024

I set up the Stripe wrapper then created a database view for my stripe products. I'm loading the products on getServerSideProps. It does work, until I refresh the page 4 times fast, then all data from the foreign table returns empty for an arbitrary amount of time. Are there rate limits to the Stripe Wrapper? Should I not be querying a view to a foreign Stripe table in realtime? I'm thinking I need to pull the entire thing and just use Stripe's API directly for listing products. Their API docs say they support 100 requests per second, but the wrapper can't even do 4...

create view
  public.stripe_products as
select
  products.id,
  products.name,
  products.active,
  products.default_price,
  products.description,
  products.created,
  products.updated,
  products.attrs,
  products.attrs -> 'metadata'::text as metadata
from
  stripe.products;

Using service role server side:

    const { data: products, error } = await supabaseAdmin.from('stripe_products').select('*').limit(3)
    const { data: prices } = await supabaseAdmin.from('stripe_prices').select('*').order('unit_amount').limit(3)

I'm thinking of using a materialized view? But only for products listings... For customer data it needs to be realtime I think. But at that point I may as well just use getStaticProps, fetch the data from their API, and then re-deploy when I make changes to my subscription pricing.

@daveycodez daveycodez added the bug Something isn't working label Jan 30, 2024
@daveycodez
Copy link
Author

daveycodez commented Jan 30, 2024

    const supabase = createAdminClient()

    for (let i = 0; i < 10; i++) {
        const { data: products, error } = await supabase.from('stripe_products').select('*').limit(3)
        console.log(`Fetch ${i}: `, products?.length)
        console.log(error)
    }

Output:

Fetch 0:  1
null
Fetch 1:  1
null
Fetch 2:  1
null
Fetch 3:  1
null
Fetch 4:  1
null
Fetch 5:  1
null
Fetch 6:  0
null
Fetch 7:  0
null
Fetch 8:  0
null
Fetch 9:  0
null

@vincenzon
Copy link

I see random empty results as well:

#237

I can't correlate when the empty results to a rate limit, but I didn't try as thoroughly as you.

I was told by supabase support to use pg_cron to build what is in effect a materialized view of the stripe data in supabase to work around this. That seems like something that should be documented if it is the official workflow.

@vincenzon
Copy link

@LeakedDave you might want to checkout the solution here:

#237

kamyshdm pushed a commit to dymium-io/supabase-wrappers that referenced this issue Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants