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

Add timeout #4

Merged
merged 1 commit into from
Feb 6, 2024
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
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