Change onExternalEvents timeout & enable custom responses

Hello everyone.

A few days ago I created a new topic about onExternalEvents response:

Basically I would like to return a custom JSON after an external event be called.

On that time I had thought I found a solution but it didn’t happen.

I figured out that I can’t call renderData function after a http request. When I do it, the externalEvents function always returns the following JSON:

{
“success”: true
}

So I would like to make a feature request:

  • There is a way to return a custom JSON on externalEvent function;
  • Change the externalEvent timeout. It will allow us to make some http requests and return whatever we want.

Please guys, let me know if you need more information about it.

Thank you so much!

External events work independently.
Where do you want to return the data as you can’t further process that data.

In case you need to see what’s the response you are getting from the HTTP request, you can print all the responses (success/error) at console and later see them at serverless logs (in case app is uploaded as custom app) or at command line (in case app is running locally).

2 Likes

When a External Event is called, it returns to the caller this default response:

{
	"success": true
}

Marcelo discovered that you can change this response using the renderData() method:

renderData(null, {field_one: 1, field_two: 2});

{
	"requestID": "1cfb25d0-3761-4e04-a910-67b65b877ee8",
	"response": {
		"field_one": 1,
		"field_two": 2
	}
}

But it seems to have a very small timeout, i.e., if you do anything on this event that takes some time, like a http request call and then set renderData(), it does not works anymore, the default value is returned before the call to renderData().

So the possibility to configure the timeout or have a higher timeout value, would be a very good feature!

3 Likes

Hi @omarcelo,

Thanks for the detailed feedback for actively exploring the platform!

I am curious about the time taken for execution in your case. Currently, the timeout is at 20s. Can you help with the average time taken in your case? (if possible, feel free to add why it takes > 20s). This will provide more insights about the challenge you are facing :smiley:

Hey @Hem

The function execution takes a few seconds in my case, even when I have to call another API in it.

Do you think there is a way to change it and allow me to send another data as response?

Unfortunately, at the moment, the timeout value is fixed and there’s little flexibility over modifying the response formats from within the onExternalEvent handler. We will consider the feedback reg the same :slight_smile:

For timeouts, if it arises as a result of using $request for making REST API calls, it can be substituted with Axios/HTTP packages (the tradeoff would be the iparam templating feature). If the total time taken for onExternalEvent handler execution exceeds 20s, this is where the platform would enforce the time limit. This value is fixed at the moment however, we will be definitely interested in use-cases that require more processing/execution time.

1 Like