Critical Issue with Stripe client
# help-and-questions
s
My Stripe integration recently stopped working but only for deployed functions. It doesn't error or anything, just silently hangs. To recreate, I created a test function
Copy code
ts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import Stripe from "https://esm.sh/stripe@11.0.0?target=deno&no-check";

serve(async () => {
  const stripe = Stripe(Deno.env.get('STRIPE_PROD_SECRET'), {
    apiVersion: "2022-11-15",
    httpClient: Stripe.createFetchHttpClient(),
  })

  return new Response(
    JSON.stringify(await stripe.customers.list()),
    { headers: { "Content-Type": "application/json" } },
  )
})
This runs just fine when serving locally but when deployed, I never get a response back. The env var does match so I know that's not the issue.
c
yh well that would be my first guess, make sure your secrets in supabase are correctly set.
where do you call the function from? I know you need these corsheaders to call it from the browser. 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey',
s
Yeah that's not the issue either. I'm already updating the headers for that reason (calling from the browser). It's happening from mobile, web, postman, every way I can think of.
c
only other thing I can think of is I always declare stripe outside (before) the serve also in your response after the headers I would add "status: 200" thats really all I can even think of
you could use a variable and get your await out of your response/JSON.stringify. and do return new Response( JSON.stringify({ response: your_variable_name }) etc. In the frontend store it again in another varibale and just console.log(your_variable_name2.response) You certain stripe.customers.list() gives back what you expect?
s
No, I had print statements everywhere. I just compacted the example for readability. Any call to a function from
stripe
just hangs, no error, just sits there until the function timeouts.
s
I have the exact same problem, everything was working fine and then out of nowhere around a day ago, everything just started to silently hang. Tried console.logging everything, and have tried every check: Created new API keys, tried on the live vs test stripe instances, and everything in between. Been stuck on this for a couple hours now. Did you figure out what was wrong?
It's all working now for some reason... I didn't actually change anything other than upgrade my stripe version from stripe@11.2.0 -> stripe@12.7.0. Not sure if it was a stripe issue or a deno issue or a supabase issue, but somehow, it's all magically resolved itself. Let me know if you're still having problems and I'll share my config
s
That was it! I was on 11.0.0. After upgrading to 12.7.0, it worked again. I'm assuming Deno made a breaking change somewhere and since edge functions are deployed to Deno Deploy, they use the latest version. Kinda wish we could control our Deno version to prevent stuff like this but oh well. Thanks for your help!