JohnJ
Convex Community2y ago
5 replies
John

{"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):

{"code":"BadJsonBody","message":"Failed to buffer the request body: length limit exceeded"}


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:

Error: [CONVEX A(stablediffusion:generateImage)] Connection lost while action was in flight


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?
Was this page helpful?