Remix ActionFunction timeouts

I’ve built a ChatGPT-enabled Remix application for a client, and it works great when run locally, but fails when run deployed on Netlify.

My suspicion in that the “ActionFunction” that calls the ChatGPT API is timing out because their API is REALLY slow-- to the tune of a minute or two to respond usually. I need the action to just wait for it and then take some actions (i.e., stuff the results into an API).

Now, I read that there’s a -background trick to get things to run asynchronously in the background. Is there some way to get a Remix action to take advantage of that? If I rename the API route filename something-background.ts does that do it?

Can anyone suggest any other method for me to allow these ChatGPT calls to run asynchronously within the context of this Remix deploy.

I know that I can do twenty other approaches if I just fire up a lambda in AWS, for instance, but I’d love to keep this all contained in this one site deployment. It’s really just a matter of giving the ActionFunction a few minutes to wait for the ChatGPT API to reply.

Open to suggestions!

Here to answer my own question again!

OK, the quickest answer was to create a Netlify function (named *-background) to submit these jobs to, instead of the Remix API.

The only gotcha there is that it doesn’t return anything, so you need to do some job management on your own. I stick a job into the database, and then the front-end polls until it’s done. Seems to work fine locally. Now to deploy and see what happens!


1 Like

Thanks for coming back and posting solution to your own question @crustyratfink :slight_smile:

Please keep us posted!