Skip to content
Open
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
27 changes: 19 additions & 8 deletions runtime/src/js/pgadmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function showErrorDialog(intervalID) {
if(!splashWindow.isVisible()) {
return;
}
clearInterval(intervalID);
clearTimeout(intervalID);
splashWindow.close();

new BrowserWindow({
Expand Down Expand Up @@ -299,22 +299,27 @@ function startDesktopMode() {
let midTime1 = currentTime + (connectionTimeout / 2);
let midTime2 = currentTime + (connectionTimeout * 2 / 3);
let pingInProgress = false;
let currentPingInterval = 100;

// ping pgAdmin server every 1 second.
// ping pgAdmin server with adaptive polling.
let pingStartTime = (new Date).getTime();
pingIntervalID = setInterval(function () {

function performPing() {
// If ping request is already send and response is not
// received no need to send another request.
if (pingInProgress)
if (pingInProgress) {
pingIntervalID = setTimeout(performPing, currentPingInterval);
return;
}

pingInProgress = true;
pingServer().then(() => {
pingInProgress = false;
splashWindow.webContents.executeJavaScript('document.getElementById(\'loader-text-status\').innerHTML = \'pgAdmin 4 started\';', true);
// Set the pgAdmin process object to misc
misc.setProcessObject(pgadminServerProcess);

clearInterval(pingIntervalID);
clearTimeout(pingIntervalID);
let appEndTime = (new Date).getTime();
misc.writeServerLog('------------------------------------------');
misc.writeServerLog('Total time taken to ping pgAdmin4 server: ' + (appEndTime - pingStartTime) / 1000 + ' Sec');
Expand All @@ -329,6 +334,7 @@ function startDesktopMode() {
// and stop pinging the server.
if (curTime >= endTime) {
showErrorDialog(pingIntervalID);
return;
}

if (curTime > midTime1) {
Expand All @@ -338,10 +344,15 @@ function startDesktopMode() {
splashWindow.webContents.executeJavaScript('document.getElementById(\'loader-text-status\').innerHTML = \'Almost there...\';', true);
}
}
});

pingInProgress = true;
}, 1000);
pingIntervalID = setTimeout(performPing, currentPingInterval);
if (currentPingInterval < 1000) {
currentPingInterval = Math.min(currentPingInterval * 2, 1000);
}
});
}

performPing();
}

// This function is used to hide the splash screen and create/launch
Expand Down
Loading