mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2177 from overleaf/bg-add-docstore-request-timeouts
add 30 second timeout on requests to docstore GitOrigin-RevId: b5e7a8926113fb50ad9931c89061d665a8d1b1e0
This commit is contained in:
parent
6c2d06c78b
commit
13a53b8fbc
2 changed files with 22 additions and 5 deletions
|
@ -18,6 +18,8 @@ const logger = require('logger-sharelatex')
|
|||
const settings = require('settings-sharelatex')
|
||||
const Errors = require('../Errors/Errors')
|
||||
|
||||
const TIMEOUT = 30 * 1000 // request timeout
|
||||
|
||||
module.exports = DocstoreManager = {
|
||||
deleteDoc(project_id, doc_id, callback) {
|
||||
if (callback == null) {
|
||||
|
@ -27,7 +29,11 @@ module.exports = DocstoreManager = {
|
|||
const url = `${
|
||||
settings.apis.docstore.url
|
||||
}/project/${project_id}/doc/${doc_id}`
|
||||
return request.del(url, function(error, res, body) {
|
||||
return request.del({ url: url, timeout: TIMEOUT }, function(
|
||||
error,
|
||||
res,
|
||||
body
|
||||
) {
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
}
|
||||
|
@ -62,6 +68,7 @@ module.exports = DocstoreManager = {
|
|||
return request.get(
|
||||
{
|
||||
url,
|
||||
timeout: TIMEOUT,
|
||||
json: true
|
||||
},
|
||||
function(error, res, docs) {
|
||||
|
@ -96,6 +103,7 @@ module.exports = DocstoreManager = {
|
|||
return request.get(
|
||||
{
|
||||
url,
|
||||
timeout: TIMEOUT,
|
||||
json: true
|
||||
},
|
||||
function(error, res, docs) {
|
||||
|
@ -139,6 +147,7 @@ module.exports = DocstoreManager = {
|
|||
return request.get(
|
||||
{
|
||||
url,
|
||||
timeout: TIMEOUT,
|
||||
json: true
|
||||
},
|
||||
function(error, res, doc) {
|
||||
|
@ -183,6 +192,7 @@ module.exports = DocstoreManager = {
|
|||
return request.post(
|
||||
{
|
||||
url,
|
||||
timeout: TIMEOUT,
|
||||
json: {
|
||||
lines,
|
||||
version,
|
||||
|
@ -228,6 +238,7 @@ module.exports = DocstoreManager = {
|
|||
_operateOnProject(project_id, method, callback) {
|
||||
const url = `${settings.apis.docstore.url}/project/${project_id}/${method}`
|
||||
logger.log({ project_id }, `calling ${method} for project in docstore`)
|
||||
// use default timeout for archiving/unarchiving/destroying
|
||||
request.post(url, function(err, res, docs) {
|
||||
if (err != null) {
|
||||
logger.warn(
|
||||
|
|
|
@ -65,11 +65,12 @@ describe('DocstoreManager', function() {
|
|||
|
||||
it('should delete the doc in the docstore api', function() {
|
||||
return this.request.del
|
||||
.calledWith(
|
||||
`${this.settings.apis.docstore.url}/project/${
|
||||
.calledWith({
|
||||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/doc/${this.doc_id}`
|
||||
)
|
||||
}/doc/${this.doc_id}`,
|
||||
timeout: 30 * 1000
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
|
@ -186,6 +187,7 @@ describe('DocstoreManager', function() {
|
|||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/doc/${this.doc_id}`,
|
||||
timeout: 30 * 1000,
|
||||
json: {
|
||||
lines: this.lines,
|
||||
version: this.version,
|
||||
|
@ -270,6 +272,7 @@ describe('DocstoreManager', function() {
|
|||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/doc/${this.doc_id}`,
|
||||
timeout: 30 * 1000,
|
||||
json: true
|
||||
})
|
||||
.should.equal(true)
|
||||
|
@ -337,6 +340,7 @@ describe('DocstoreManager', function() {
|
|||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/doc/${this.doc_id}?include_deleted=true`,
|
||||
timeout: 30 * 1000,
|
||||
json: true
|
||||
})
|
||||
.should.equal(true)
|
||||
|
@ -402,6 +406,7 @@ describe('DocstoreManager', function() {
|
|||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/doc`,
|
||||
timeout: 30 * 1000,
|
||||
json: true
|
||||
})
|
||||
.should.equal(true)
|
||||
|
@ -464,6 +469,7 @@ describe('DocstoreManager', function() {
|
|||
url: `${this.settings.apis.docstore.url}/project/${
|
||||
this.project_id
|
||||
}/ranges`,
|
||||
timeout: 30 * 1000,
|
||||
json: true
|
||||
})
|
||||
.should.equal(true)
|
||||
|
|
Loading…
Reference in a new issue