Skip to content

Commit

Permalink
Add timeout (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv authored Feb 6, 2024
1 parent 0e1941f commit dfd904f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ class MeetingDataProcessor {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
const callbackName = `jsonpCallback_${Date.now()}`;
let timeoutId = setTimeout(() => {
const errorMsg = "Timeout: No response from server";
MeetingDataProcessor.displayError(errorMsg);
document.body.removeChild(script);
delete window[callbackName];
reject(new Error(errorMsg));
}, 10000); // 10 seconds timeout

window[callbackName] = (data) => {
clearTimeout(timeoutId);
document.body.removeChild(script);
delete window[callbackName];

Expand Down Expand Up @@ -231,6 +239,7 @@ class MeetingDataProcessor {
// start the export process
exportData(query) {
if (!query.includes("/client_interface/jsonp")) {
MeetingDataProcessor.hideLinks();
MeetingDataProcessor.displayError(
"Invalid BMLT query URL, must use jsonp endpoint."
);
Expand Down

0 comments on commit dfd904f

Please sign in to comment.