From aac835923843dbb4e0a5e717f37be002b2ef5699 Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Mon, 6 Apr 2020 10:42:38 +0200 Subject: [PATCH] Set client timeout limit in chainGetJSON() (#2482) By setting a client side timeout one can avoid net::ERR_NETWORK_IO_SUSPENDED errors caused by the OS network layer being suspended [1]. This allows the client to handle higher level errors. The jQuery.getJSON() function does not have a parameter for timeouts. [1]: https://cs.chromium.org/chromium/src/net/http/http_network_layer.cc?q=ERR_NETWORK_IO_SUSPENDED&sq=package:chromium&dr=C&l=42 --- main/webapp/modules/core/scripts/util/ajax.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/webapp/modules/core/scripts/util/ajax.js b/main/webapp/modules/core/scripts/util/ajax.js index 5d7aa70be..5e9a2af19 100644 --- a/main/webapp/modules/core/scripts/util/ajax.js +++ b/main/webapp/modules/core/scripts/util/ajax.js @@ -42,10 +42,15 @@ Ajax.chainGetJSON = function() { var data = a[i++]; var callback = a[i++]; - $.getJSON(url, data, function(o) { + $.ajax({ + dataType: "json", + url: url, + data: data, + timeout: 30000 + }).done(function(o) { callback(o); next(); - }, "json"); + }); } else if (i < a.length) { var finalCallback = a[i++]; finalCallback();