Request timeout

Options
Hi,
Is there a way to send a 200 response before the end of the function?
I am working with a webhook that allows only 2000ms before it is considered as timed out.

Many thanks 

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    I think the technical problem you have is asynchronous invocation. You want process A to trigger  process B to run without process A having to wait for the latter.  

    It can be a little tricky, but one way to do this is have webhook A call webhook B with a super-short timeout, like 500ms. That way webhook B will keep on running with nobody to answer to, while webhook A returns nice and quick. 

    Another way is to have webhook A store information from the request in a table, and then have a background task running frequently use that table as a queue to run whatever processing the webhook was supposed to do.

    A third option is to use Zapier with a silent-return webhook trigger to basically perform the same operation as my first choice, except Zapier will give you more "wrapping" to make sure process B did its job. 

    All of these involve a little ceremony and experimentation, but it's completely do-able! 
  • Victor Nihoul
    Options
     I wish you came up with a simpler answer 🥴
    Thanks, I will probably opt-in for asynchronous process running!

    Appreciate your help!
  • udigolan
    udigolan Member
    Options

    Hi Everyone,

    I came across the same issue. Bubble is limiting the synchronous API call to 60 secs.

    Is there a way on Xano to expose an asynchronous API (or asynchronous function)? or alternatively to let Xano API trigger a background task (instead of being time-triggered)?

    Is there any other straightforward way to overcome this issue? (I was reading the above and these are viable solutions but I am after a simple one)

    Thanks!

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    Hey @udigolan the options are still the same in Xano: run an external API endpoint with a timeout (usually 1s) that makes it effectively asynchronous, or add the request to a queue (usually a record in a database table) that is later handled by a background task.

  • udigolan
    udigolan Member
    Options

    @Ray Deck Thanks!

    Re the 1st option - I'm missing here something. Let's assume I defined such a timeout. To complete the function execution right now it takes ~70 seconds (all tasks which I would like to be done async). So what should I define in Xano to let the execution of these tasks continue when the 1s function (timedout) returns control to Bubble?

    Thanks for your help.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    You set the timeout of the external API call to its minimum (1s). That way the called code will kick off, but the calling stack won't wait for it to finish. You get an error message in your API response (timeout exceeded) but your stack won't crash - it just moves on.