Fetch timeout in script block?

Topic Labels: Scripting extentions
2355 3
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

Hi everyone,

I’m executing a post request via the customer script app pointing to an integromat webhook to trigger an automation. The integromat scenario takes a while to run (approx. 45 seconds), as it duplicates heavy Google Slides presentations.
The scenario ends by a the simple webhook response such as this one:

  "body": {"message":"Scenario successful."},

I’m receiving the following error:

Unexpected token A in JSON at position 0

This would normally indicate that the JSON string is malformatted and can’t be parsed. But a few tests, it looks like the await response.json() line is executed before the response is actually returned from integromat (it waits ~40seconds for a response before moving on).

I have tested a mock scenario (running in a few seconds) returning the same json string and it works just fine.

According to the researches I’ve made, default fetch() requests timeout at the time indicated by the browser which would be 300 seconds in Chrome, but I’m wondering if there is any extra limitation coming from the scripting block environment?

Here is the code I’m executing:

    const options = {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json;charset=UTF-8'
      body: body
    var response = await fetch(url, options)
    var data = await response.json();

Thanks a lot for your help!

3 Replies 3

Welcome to the community, @xad9119!

I don’t know the direct answer to your question, but within your Integromat scenario, you can go into the scenario settings (button at the bottom of the screen) and check the checkbox for “auto commit”. This will immediately send your webhook response back to Airtable, without waiting for the entire Integromat scenario to finish processing.

6 - Interface Innovator
6 - Interface Innovator

Hi @ScottWorld !

Thanks for your help. That’s indeed an interesting workaround that could work, but I guess that I’m still blocked if my script expects some information from the scenario to work properly?

If that’s the case, then I would either perform al of those subsequent activities with Integromat, or send the information back to Airtable and then have a completely different Airtable automation process it from there.