{"code":"BadJsonBody","message":"Failed to buffer the request body: length limit exceeded"}
I'm currently trying to use the stable diffusion image-to-image api to generate images and save them to Convex storage.
I initially tried using a Nextjs API route to call the api, and then call a Convex action to store each generated image. The issue is that the API returns images as base64 encoded strings. When I try to pass the string to the Convex action, some images will throw the following error and not get stored (seems like the image strings are too long):
I then tried creating a Convex action to make the API request directly in an action and store the images. However, if I try to generate and store more than ~3 images in a single request, calling the action from the client throws the following error:
The images get stored successfully, but because of the timeout, I'm not getting the return data to display.
Any suggestions for a better way to set this up?
4 Replies
This is the Convex action that times out when called directly.
These are the helper functions used in the action:
Hi John, do you have the instance name where you're seeing these errors in the Action? You can find in the url on your dashboard or as part of your deployment URL. If you post that here or DM me I can look into the connection lost issue.
In the meantime, you may be able to use your original approach, but then upload the blobs directly from the client. You can then pass the storage IDs into an action or mutation to store the user <-> id mapping. See https://docs.convex.dev/file-storage/upload-files for an example of how to do this.
Uploading and Storing Files | Convex Developer Hub
Files can be uploaded by your users and stored in Convex.
Instance name: precious-squid-669
Thanks. We need to improve the errror message, but I believe you're seeing that error because the size of the return value from your Action,
images
, exceeds an internal limit. Can you modify your Action to return the Storage IDs, rather than the image blobs?