Skip to content

Commit 084bbd9

Browse files
committed
Ask only once
1 parent f0f5052 commit 084bbd9

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

services/static-webserver/client/source/class/osparc/data/model/IframeHandler.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
8787
.resetSequence();
8888

8989
this.__unresponsiveRetries = 5;
90-
this.__nodeState(false);
90+
this.__nodeState();
9191

9292
this.getIFrame().resetSource();
9393
},
@@ -156,7 +156,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
156156
return statusText + " " + node.getLabel() + " <span style='font-size: 16px;font-weight: normal;'><sub>v" + versionDisplay + "</sub></span>";
157157
},
158158

159-
__nodeState: function(starting=true) {
159+
__nodeState: function() {
160160
// Check if study is still there
161161
if (this.getStudy() === null || this.__stopRequestingStatus === true) {
162162
this.setPolling(false);
@@ -176,7 +176,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
176176
}
177177
};
178178
osparc.data.Resources.fetch("studies", "getNode", params)
179-
.then(data => this.__onNodeState(data, starting))
179+
.then(data => this.onNodeState(data))
180180
.catch(err => {
181181
let errorMsg = `Error retrieving ${node.getLabel()} status: ${err}`;
182182
if ("status" in err && err.status === 406) {
@@ -203,8 +203,6 @@ qx.Class.define("osparc.data.model.IframeHandler", {
203203
};
204204
node.fireDataEvent("showInLogger", retryMsgData);
205205
this.__unresponsiveRetries--;
206-
const interval = Math.floor(Math.random() * 5000) + 3000;
207-
setTimeout(() => this.__nodeState(), interval);
208206
} else {
209207
this.setPolling(false);
210208
node.getStatus().setInteractive("failed");
@@ -213,20 +211,18 @@ qx.Class.define("osparc.data.model.IframeHandler", {
213211
});
214212
},
215213

216-
__onNodeState: function(data, starting=true) {
214+
onNodeState: function(data) {
217215
const serviceState = data["service_state"];
218216
const nodeId = data["service_uuid"];
219217
const node = this.getNode();
220218
const status = node.getStatus();
221-
let nextPollIn = null;
222219
let pollingInNextStage = null;
223220
switch (serviceState) {
224221
case "idle": {
225222
status.setInteractive(serviceState);
226-
if (starting && this.__unresponsiveRetries>0) {
223+
if (this.__unresponsiveRetries>0) {
227224
// a bit of a hack. We will get rid of it when the backend pushes the states
228225
this.__unresponsiveRetries--;
229-
nextPollIn = 2000;
230226
} else {
231227
this.setPolling(false);
232228
}
@@ -248,26 +244,19 @@ qx.Class.define("osparc.data.model.IframeHandler", {
248244
node.fireDataEvent("showInLogger", msgData);
249245
}
250246
status.setInteractive(serviceState);
251-
nextPollIn = 10000;
252247
break;
253248
}
254249
case "stopping":
255250
case "unknown":
256251
case "starting":
257252
case "pulling": {
258253
status.setInteractive(serviceState);
259-
nextPollIn = 5000;
260254
break;
261255
}
262256
case "running": {
263257
if (nodeId !== node.getNodeId()) {
264258
break;
265259
}
266-
if (!starting) {
267-
status.setInteractive("stopping");
268-
nextPollIn = 5000;
269-
break;
270-
}
271260
const {
272261
srvUrl,
273262
isDynamicV2
@@ -297,9 +286,7 @@ qx.Class.define("osparc.data.model.IframeHandler", {
297286
console.error(serviceState, "service state not supported");
298287
break;
299288
}
300-
if (nextPollIn) {
301-
qx.event.Timer.once(() => this.__nodeState(starting), this, nextPollIn);
302-
} else if (pollingInNextStage !== true) {
289+
if (pollingInNextStage !== true) {
303290
this.setPolling(false);
304291
}
305292
},

0 commit comments

Comments
 (0)