Skip to content

Commit

Permalink
Set xhr timeout + ontimeout logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aksylumoed committed Mar 24, 2024
1 parent 864c12c commit 2ee0c90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion artworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function displayInitialArtwork(index: number): void {
initialArtworkElement.style.display = "block";

if (loadingIndicator) {
loadingIndicator.innerHTML = `fetching...`;
loadingIndicator.innerHTML = `fetching...<br><br>`;
loadingIndicator.style.display = 'none';
}
}
Expand Down Expand Up @@ -114,6 +114,7 @@ function loadImageWithProgress(
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.timeout = 60000; // Set a longer timeout, if necessary

xhr.onprogress = (event: ProgressEvent) => {
if (event.lengthComputable) {
Expand All @@ -135,6 +136,10 @@ function loadImageWithProgress(
}
};

xhr.ontimeout = function() {
console.error("The request for " + url + " timed out.");
};

xhr.send();
}

Expand Down

0 comments on commit 2ee0c90

Please sign in to comment.