Network timeout on query trigger in script does not throw an error from the returned promise

When manually triggering a query from a script, if the query times out, Retool does not throw an error. Instead it "successfully" returns a value of "undefined".

See the sample code below. Assume query1 has a timeout of 1s and it reaches out to an endpoint which has a delay of 2s, meaning the query should always hit a network timeout.

(async () => {
  try {
    // Assume the following query fails with a network timeout
    const res = await query1.trigger();
    // Logic continues here, but should have gone into the catch block
  } catch (err) {
    // Logic does NOT make it here even though the query failed
  }
})();

// same thing for... 

query1.trigger()
  .then(res => { // Logic goes here })
  .catch(err => { // Does NOT make it here })

The catch block is never hit, even though query1 technically failed.

Is this a limitation of the trigger() method? Does it not see network failures as errors?

Wrapping the trigger() method in a promise and using the onSuccess/onFailure callbacks works:

(async () => {
  try {
    const res = await test();
  } catch (err) {
    // Logic correctly makes it here
  }
})();

function test() {
  return new Promise((resolve, reject) => {
    query1.trigger({
      onSuccess: (res) => resolve(res),
      onFailure: (err) => reject(err)
    });
  });
}

My temporary solution has been to wrap all queries with the following:

function query(queryRef, additionalScope) {
  return new Promise((resolve, reject) => {
    const config = {
      onSuccess: res => resolve(res),
      onFailure: err => reject(err)
    };
    if (additionalScope) {
      config.additionalScope = additionalScope;
    }
    queryRef.trigger(config);
  });
}

(async () => {
  try {
    const res = await query(query1);
  } catch (err) {
    // Hits the catch as expected
  }
})();

Hi @mbates! I believe this is related to a bug are looking into on our end :disappointed: I'm glad you have a temporary solution for the meantime!