Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restart timeout on progress, catch error #2170

Merged
merged 2 commits into from
Mar 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions sd-card/html/backup.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ <h2>Restore Configuration</h2>
xhr.timeout = 5000; // time in milliseconds
}
else if (retry == 2) { // longer timeout
xhr.timeout = 20000; // time in milliseconds
xhr.timeout = 10000; // time in milliseconds
}
else if (retry == 3) { // longer timeout
xhr.timeout = 30000; // time in milliseconds
xhr.timeout = 20000; // time in milliseconds
}
else { // very long timeout
xhr.timeout = 60000; // time in milliseconds
xhr.timeout = 30000; // time in milliseconds
}

xhr.onload = () => { // Request finished
Expand All @@ -146,6 +146,20 @@ <h2>Restore Configuration</h2>
}
};

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
console.log("Timeout on fetching " + url + "!");
if (retry > 5) {
Expand Down