File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import Data.Int (toNumber, round)
28
28
import Data.Maybe (Maybe (..), maybe )
29
29
import Data.Nullable (Nullable (), toNullable )
30
30
import DOM.XHR (XMLHttpRequest ())
31
- import Math (pow )
31
+ import Math (max , pow )
32
32
import Network.HTTP.Affjax.Request
33
33
import Network.HTTP.Affjax.Response
34
34
import Network.HTTP.Method (Method (..), methodToString )
@@ -148,14 +148,17 @@ retry milliseconds run req = do
148
148
StatusCode 200 -> Right resp
149
149
_ -> Left resp
150
150
151
+ -- maximum delay in milliseconds
152
+ maxDelay = 30.0 * 1000.0
153
+
151
154
go failureVar n = do
152
155
result <- run req
153
156
case assert200 result of
154
157
Right b -> pure b
155
158
Left resp -> do
156
159
putVar failureVar resp
157
160
-- TODO: is this too steep?
158
- let delay = round $ toNumber 1000 * pow (toNumber 2 ) ( toNumber (n - 1 ))
161
+ let delay = round $ max maxDelay $ 1000.0 * ( pow 2.0 $ toNumber (n - 1 ))
159
162
later' delay $ go failureVar (n + 1 )
160
163
161
164
-- | Run a request directly without using `Aff`.
You can’t perform that action at this time.
0 commit comments