mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-11 14:07:00 +03:00
restart timeout on progress, catch error (#2170)
* restart timeout on progress, catch error * . --------- Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -122,13 +122,13 @@ function fetchFiles(urls, filesData, index, retry, zipFilename) {
|
|||||||
xhr.timeout = 5000; // time in milliseconds
|
xhr.timeout = 5000; // time in milliseconds
|
||||||
}
|
}
|
||||||
else if (retry == 2) { // longer timeout
|
else if (retry == 2) { // longer timeout
|
||||||
xhr.timeout = 20000; // time in milliseconds
|
xhr.timeout = 10000; // time in milliseconds
|
||||||
}
|
}
|
||||||
else if (retry == 3) { // longer timeout
|
else if (retry == 3) { // longer timeout
|
||||||
xhr.timeout = 30000; // time in milliseconds
|
xhr.timeout = 20000; // time in milliseconds
|
||||||
}
|
}
|
||||||
else { // very long timeout
|
else { // very long timeout
|
||||||
xhr.timeout = 60000; // time in milliseconds
|
xhr.timeout = 30000; // time in milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onload = () => { // Request finished
|
xhr.onload = () => { // Request finished
|
||||||
@@ -146,6 +146,20 @@ function fetchFiles(urls, filesData, index, retry, zipFilename) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xhr.onprogress = (e) => { // XMLHttpRequest progress ... extend timeout
|
||||||
|
xhr.timeout = xhr.timeout + 500;
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.onerror = (e) => { // XMLHttpRequest error loading
|
||||||
|
console.log("Error on fetching " + url + "!");
|
||||||
|
if (retry > 5) {
|
||||||
|
setStatus("<span style=\"color: red\">Backup failed, please restart the device and try again!</span>");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fetchFiles(urls, filesData, index, retry+1, zipFilename);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
xhr.ontimeout = (e) => { // XMLHttpRequest timed out
|
xhr.ontimeout = (e) => { // XMLHttpRequest timed out
|
||||||
console.log("Timeout on fetching " + url + "!");
|
console.log("Timeout on fetching " + url + "!");
|
||||||
if (retry > 5) {
|
if (retry > 5) {
|
||||||
|
|||||||
Reference in New Issue
Block a user