How to elegantly handle errors in response to XMLHTTPRequests

0
We have a Mendix app that is experiencing occasional 503s in response to XHR POST requests. Assume troubleshooting at the network level is not possible. These failures are only momentary and subsequent XHRs go through fine, but they do result in the user receiving an error message. Since the requests are made from the user’s device, how can we silently retry any request that results in an error on the client side up to perhaps a maximum of X retries? N.B. these XHRs are generated by Mendix’s usual back and forth, i.e. they are not being explicitly triggered in a java action or anything like that.   ###### Update ###### To clarify, this is a self-hosted Mendix app. It’s not running on the Mendix cloud. Thank you.
asked
2 answers
1

To get rid of the error dialog add the following javascript to the page
This does not address the problem or retry but at least the user will not see the error.

if ( window.connectionErrorOveride != true )  {
  window.connectionErrorOveride = true;
  var oldTranslate = mx.ui.translate ;
  mx.ui.translate = function(t, e, n, i) {
    if ( e == "connection_error" ) { // or "internal_error" or "sync_error"
      return null;
    } else {
      return oldTranslate.apply(this, arguments);
    }
  }
}

https://forum.mendix.com/link/questions/95907

answered
0

Hi Stefan,

I think these errors were caused by some outage in the Mendix Cloud that happened on 7th October 2020. We also received complaints from our users about random errors occurring throughout the app. We have not had these errors before, and we no longer have them today. So I assume it was a temporary thing.

-Andrej

answered