mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #53 from overleaf/em-doc-updater-404s
Do not log error on doc updater 404
This commit is contained in:
commit
a579a83389
2 changed files with 25 additions and 24 deletions
|
@ -24,7 +24,7 @@ module.exports = DocumentUpdaterManager =
|
||||||
catch error
|
catch error
|
||||||
return callback(error)
|
return callback(error)
|
||||||
callback null, body?.lines, body?.version, body?.ranges, body?.ops
|
callback null, body?.lines, body?.version, body?.ranges, body?.ops
|
||||||
else if res.statusCode == 422 # Unprocessable Entity
|
else if res.statusCode in [404, 422]
|
||||||
err = new Error("doc updater could not load requested ops")
|
err = new Error("doc updater could not load requested ops")
|
||||||
err.statusCode = res.statusCode
|
err.statusCode = res.statusCode
|
||||||
logger.warn {err, project_id, doc_id, url, fromVersion}, "doc updater could not load requested ops"
|
logger.warn {err, project_id, doc_id, url, fromVersion}, "doc updater could not load requested ops"
|
||||||
|
@ -54,7 +54,7 @@ module.exports = DocumentUpdaterManager =
|
||||||
err.statusCode = res.statusCode
|
err.statusCode = res.statusCode
|
||||||
logger.error {err, project_id}, "document updater returned failure status code: #{res.statusCode}"
|
logger.error {err, project_id}, "document updater returned failure status code: #{res.statusCode}"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
|
|
||||||
queueChange: (project_id, doc_id, change, callback = ()->)->
|
queueChange: (project_id, doc_id, change, callback = ()->)->
|
||||||
allowedKeys = [ 'doc', 'op', 'v', 'dupIfSource', 'meta', 'lastV', 'hash']
|
allowedKeys = [ 'doc', 'op', 'v', 'dupIfSource', 'meta', 'lastV', 'hash']
|
||||||
change = _.pick change, allowedKeys
|
change = _.pick change, allowedKeys
|
||||||
|
|
|
@ -10,13 +10,13 @@ describe 'DocumentUpdaterManager', ->
|
||||||
@doc_id = "doc-id-394"
|
@doc_id = "doc-id-394"
|
||||||
@lines = ["one", "two", "three"]
|
@lines = ["one", "two", "three"]
|
||||||
@version = 42
|
@version = 42
|
||||||
@settings =
|
@settings =
|
||||||
apis: documentupdater: url: "http://doc-updater.example.com"
|
apis: documentupdater: url: "http://doc-updater.example.com"
|
||||||
redis: documentupdater:
|
redis: documentupdater:
|
||||||
key_schema:
|
key_schema:
|
||||||
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
pendingUpdates: ({doc_id}) -> "PendingUpdates:#{doc_id}"
|
||||||
@rclient = {auth:->}
|
@rclient = {auth:->}
|
||||||
|
|
||||||
@DocumentUpdaterManager = SandboxedModule.require modulePath,
|
@DocumentUpdaterManager = SandboxedModule.require modulePath,
|
||||||
requires:
|
requires:
|
||||||
'settings-sharelatex':@settings
|
'settings-sharelatex':@settings
|
||||||
|
@ -59,17 +59,19 @@ describe 'DocumentUpdaterManager', ->
|
||||||
it "should return an error to the callback", ->
|
it "should return an error to the callback", ->
|
||||||
@callback.calledWith(@error).should.equal true
|
@callback.calledWith(@error).should.equal true
|
||||||
|
|
||||||
describe "when the document updater returns a 422 status code", ->
|
[404, 422].forEach (statusCode) ->
|
||||||
beforeEach ->
|
describe "when the document updater returns a #{statusCode} status code", ->
|
||||||
@request.get = sinon.stub().callsArgWith(1, null, { statusCode: 422 }, "")
|
beforeEach ->
|
||||||
@DocumentUpdaterManager.getDocument @project_id, @doc_id, @fromVersion, @callback
|
@request.get = sinon.stub().callsArgWith(1, null, { statusCode }, "")
|
||||||
|
@DocumentUpdaterManager.getDocument @project_id, @doc_id, @fromVersion, @callback
|
||||||
|
|
||||||
it "should return the callback with an error", ->
|
it "should return the callback with an error", ->
|
||||||
err = new Error("doc updater could not load requested ops")
|
@callback.called.should.equal(true)
|
||||||
err.statusCode = 422
|
err = @callback.getCall(0).args[0]
|
||||||
@callback
|
err.should.have.property('statusCode', statusCode)
|
||||||
.calledWith(err)
|
err.should.have.property('message', "doc updater could not load requested ops")
|
||||||
.should.equal true
|
@logger.error.called.should.equal(false)
|
||||||
|
@logger.warn.called.should.equal(true)
|
||||||
|
|
||||||
describe "when the document updater returns a failure error code", ->
|
describe "when the document updater returns a failure error code", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -77,11 +79,11 @@ describe 'DocumentUpdaterManager', ->
|
||||||
@DocumentUpdaterManager.getDocument @project_id, @doc_id, @fromVersion, @callback
|
@DocumentUpdaterManager.getDocument @project_id, @doc_id, @fromVersion, @callback
|
||||||
|
|
||||||
it "should return the callback with an error", ->
|
it "should return the callback with an error", ->
|
||||||
err = new Error("doc updater returned failure status code: 500")
|
@callback.called.should.equal(true)
|
||||||
err.statusCode = 500
|
err = @callback.getCall(0).args[0]
|
||||||
@callback
|
err.should.have.property('statusCode', 500)
|
||||||
.calledWith(err)
|
err.should.have.property('message', "doc updater returned a non-success status code: 500")
|
||||||
.should.equal true
|
@logger.error.called.should.equal(true)
|
||||||
|
|
||||||
describe 'flushProjectToMongoAndDelete', ->
|
describe 'flushProjectToMongoAndDelete', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -113,11 +115,10 @@ describe 'DocumentUpdaterManager', ->
|
||||||
@DocumentUpdaterManager.flushProjectToMongoAndDelete @project_id, @callback
|
@DocumentUpdaterManager.flushProjectToMongoAndDelete @project_id, @callback
|
||||||
|
|
||||||
it "should return the callback with an error", ->
|
it "should return the callback with an error", ->
|
||||||
err = new Error("doc updater returned failure status code: 500")
|
@callback.called.should.equal(true)
|
||||||
err.statusCode = 500
|
err = @callback.getCall(0).args[0]
|
||||||
@callback
|
err.should.have.property('statusCode', 500)
|
||||||
.calledWith(err)
|
err.should.have.property('message', "document updater returned a failure status code: 500")
|
||||||
.should.equal true
|
|
||||||
|
|
||||||
describe 'queueChange', ->
|
describe 'queueChange', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue