Closed rjwignar closed 7 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
ai-chef-bot | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 8, 2024 4:21pm |
Hey @rjwignar, I'm trying to test it but it says I need to request access when I click on the preview deployment link? Is this a problem on my end or do I need access to test it?. I hopefully sent a request so I can test it asap. Sorry it took a while.
Hey @rjwignar, I'm trying to test it but it says I need to request access when I click on the preview deployment link? Is this a problem on my end or do I need access to test it?. I hopefully sent a request so I can test it asap. Sorry it took a while.
@JohnPhillipO hey JP I’m not home rn but I was able to give you access just now. Please try again and let me know. The hobby plan is weird because I can only grant access to 1 additional user at a time. I’ll know more details when I return home but for now you should be able too access the preview
This fixes #152
Summary
If you try generating recipes on the current deployment, you'll get Error 504: Gateway Timeout Error. This is because the recipe generation takes around 20-30 seconds, and the Vercel Free/Hobby tier supports a max serverless function timeout of 10 seconds.
There are two solutions:
This PR extends the generateRecipe handler to support the Edge runtime (meaning we can run it as an Edge function). You can test the preview deployment and confirm you can generate recipes.
What's left to do (remaining issues)
Code Refactor
When supporting the Edge runtime, I noticed a lot of reused code. I'll be refactoring this handler in a follow-up.
Edge Functions Timeout
Edge functions have an unlimited runtime, but must start returning a response within 25 seconds. If you provide complex specifications (like multiple diets) and it takes more than 25 seconds to get a full response, we still get a Gateway timeout error on the deployment. The solution here is to stream responses, but streaming a JSON response can be a challenge.
I'm working on a followup to address that issue. But for now this PR restores most basic recipe generation on the deployment. Alternatively, we can use the Vercel Pro trial to have a max timeout of 5 minutes. However, the trial lasts 2 weeks. I'll have to start the trial next week if we go this route.