mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Reduce retry delay to 10ms, and refactor
This commit is contained in:
parent
dc8d08c030
commit
c3465cf3d4
2 changed files with 7 additions and 6 deletions
|
@ -1,8 +1,11 @@
|
|||
request = require "requestretry"
|
||||
Settings = require "settings-sharelatex"
|
||||
Errors = require "./Errors"
|
||||
Metrics = require "./Metrics"
|
||||
logger = require "logger-sharelatex"
|
||||
request = (require("requestretry")).defaults({
|
||||
maxAttempts: 2
|
||||
retryDelay: 10
|
||||
})
|
||||
|
||||
# We have to be quick with HTTP calls because we're holding a lock that
|
||||
# expires after 30 seconds. We can't let any errors in the rest of the stack
|
||||
|
@ -28,7 +31,6 @@ module.exports = PersistenceManager =
|
|||
sendImmediately: true
|
||||
jar: false
|
||||
timeout: MAX_HTTP_REQUEST_LENGTH
|
||||
maxAttempts: 2 # for requestretry
|
||||
}, (error, res, body) ->
|
||||
return callback(error) if error?
|
||||
if res.statusCode >= 200 and res.statusCode < 300
|
||||
|
@ -66,7 +68,6 @@ module.exports = PersistenceManager =
|
|||
sendImmediately: true
|
||||
jar: false
|
||||
timeout: MAX_HTTP_REQUEST_LENGTH
|
||||
maxAttempts: 2 # for requestretry
|
||||
}, (error, res, body) ->
|
||||
return callback(error) if error?
|
||||
if res.statusCode >= 200 and res.statusCode < 300
|
||||
|
|
|
@ -7,8 +7,10 @@ Errors = require "../../../../app/js/Errors"
|
|||
|
||||
describe "PersistenceManager", ->
|
||||
beforeEach ->
|
||||
@request = sinon.stub()
|
||||
@request.defaults = () => @request
|
||||
@PersistenceManager = SandboxedModule.require modulePath, requires:
|
||||
"requestretry": @request = sinon.stub()
|
||||
"requestretry": @request
|
||||
"settings-sharelatex": @Settings = {}
|
||||
"./Metrics": @Metrics =
|
||||
Timer: class Timer
|
||||
|
@ -50,7 +52,6 @@ describe "PersistenceManager", ->
|
|||
sendImmediately: true
|
||||
jar: false
|
||||
timeout: 5000
|
||||
maxAttempts: 2
|
||||
})
|
||||
.should.equal true
|
||||
|
||||
|
@ -130,7 +131,6 @@ describe "PersistenceManager", ->
|
|||
sendImmediately: true
|
||||
jar: false
|
||||
timeout: 5000
|
||||
maxAttempts: 2
|
||||
})
|
||||
.should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue