From 798add36421df843d2f53cfa65e0e819db090cca Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 22 Jun 2018 14:40:21 +0200 Subject: [PATCH] Test stabilization: Limited window for possible race condition between server restart and availability check. --- .../app/controllers/widget/maintenance.coffee | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/app/controllers/widget/maintenance.coffee b/app/assets/javascripts/app/controllers/widget/maintenance.coffee index 004554342..02b94a158 100644 --- a/app/assets/javascripts/app/controllers/widget/maintenance.coffee +++ b/app/assets/javascripts/app/controllers/widget/maintenance.coffee @@ -1,5 +1,5 @@ class Widget extends App.Controller - errorCount: 0 + serverRestarted: false constructor: -> super @@ -109,21 +109,24 @@ class Widget extends App.Controller ) @delay(message, 2000) - checkAvailability: (delay) => + checkAvailability: (timeout) => delay = => @ajax( - id: 'check_availability' - type: 'get' - url: "#{@apiPath}/available" + id: 'check_availability' + type: 'get' + url: "#{@apiPath}/available" success: (data) => - if @errorCount is 0 - @checkAvailability() + if @serverRestarted + @windowReload() return - @windowReload() - error: => - @errorCount += 1 + @checkAvailability() + error: => + @serverRestarted = true + @checkAvailability(2000) ) - @delay(delay, 2000) + + timeout ?= 1000 + @delay(delay, timeout) App.Config.set('maintenance', Widget, 'Widgets')