Open LeakedDave opened 5 months ago
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
I see random empty results as well:
https://github.com/supabase/wrappers/issues/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.
@LeakedDave you might want to checkout the solution here:
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...
Using service role server side:
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.