mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 02:05:22 -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 settings = require('settings-sharelatex')
|
||||||
const Errors = require('../Errors/Errors')
|
const Errors = require('../Errors/Errors')
|
||||||
|
|
||||||
|
const TIMEOUT = 30 * 1000 // request timeout
|
||||||
|
|
||||||
module.exports = DocstoreManager = {
|
module.exports = DocstoreManager = {
|
||||||
deleteDoc(project_id, doc_id, callback) {
|
deleteDoc(project_id, doc_id, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
|
@ -27,7 +29,11 @@ module.exports = DocstoreManager = {
|
||||||
const url = `${
|
const url = `${
|
||||||
settings.apis.docstore.url
|
settings.apis.docstore.url
|
||||||
}/project/${project_id}/doc/${doc_id}`
|
}/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) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
@ -62,6 +68,7 @@ module.exports = DocstoreManager = {
|
||||||
return request.get(
|
return request.get(
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
timeout: TIMEOUT,
|
||||||
json: true
|
json: true
|
||||||
},
|
},
|
||||||
function(error, res, docs) {
|
function(error, res, docs) {
|
||||||
|
@ -96,6 +103,7 @@ module.exports = DocstoreManager = {
|
||||||
return request.get(
|
return request.get(
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
timeout: TIMEOUT,
|
||||||
json: true
|
json: true
|
||||||
},
|
},
|
||||||
function(error, res, docs) {
|
function(error, res, docs) {
|
||||||
|
@ -139,6 +147,7 @@ module.exports = DocstoreManager = {
|
||||||
return request.get(
|
return request.get(
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
timeout: TIMEOUT,
|
||||||
json: true
|
json: true
|
||||||
},
|
},
|
||||||
function(error, res, doc) {
|
function(error, res, doc) {
|
||||||
|
@ -183,6 +192,7 @@ module.exports = DocstoreManager = {
|
||||||
return request.post(
|
return request.post(
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
timeout: TIMEOUT,
|
||||||
json: {
|
json: {
|
||||||
lines,
|
lines,
|
||||||
version,
|
version,
|
||||||
|
@ -228,6 +238,7 @@ module.exports = DocstoreManager = {
|
||||||
_operateOnProject(project_id, method, callback) {
|
_operateOnProject(project_id, method, callback) {
|
||||||
const url = `${settings.apis.docstore.url}/project/${project_id}/${method}`
|
const url = `${settings.apis.docstore.url}/project/${project_id}/${method}`
|
||||||
logger.log({ project_id }, `calling ${method} for project in docstore`)
|
logger.log({ project_id }, `calling ${method} for project in docstore`)
|
||||||
|
// use default timeout for archiving/unarchiving/destroying
|
||||||
request.post(url, function(err, res, docs) {
|
request.post(url, function(err, res, docs) {
|
||||||
if (err != null) {
|
if (err != null) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|
|
@ -65,11 +65,12 @@ describe('DocstoreManager', function() {
|
||||||
|
|
||||||
it('should delete the doc in the docstore api', function() {
|
it('should delete the doc in the docstore api', function() {
|
||||||
return this.request.del
|
return this.request.del
|
||||||
.calledWith(
|
.calledWith({
|
||||||
`${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/doc/${this.doc_id}`
|
}/doc/${this.doc_id}`,
|
||||||
)
|
timeout: 30 * 1000
|
||||||
|
})
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -186,6 +187,7 @@ describe('DocstoreManager', function() {
|
||||||
url: `${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/doc/${this.doc_id}`,
|
}/doc/${this.doc_id}`,
|
||||||
|
timeout: 30 * 1000,
|
||||||
json: {
|
json: {
|
||||||
lines: this.lines,
|
lines: this.lines,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
|
@ -270,6 +272,7 @@ describe('DocstoreManager', function() {
|
||||||
url: `${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/doc/${this.doc_id}`,
|
}/doc/${this.doc_id}`,
|
||||||
|
timeout: 30 * 1000,
|
||||||
json: true
|
json: true
|
||||||
})
|
})
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
@ -337,6 +340,7 @@ describe('DocstoreManager', function() {
|
||||||
url: `${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/doc/${this.doc_id}?include_deleted=true`,
|
}/doc/${this.doc_id}?include_deleted=true`,
|
||||||
|
timeout: 30 * 1000,
|
||||||
json: true
|
json: true
|
||||||
})
|
})
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
@ -402,6 +406,7 @@ describe('DocstoreManager', function() {
|
||||||
url: `${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/doc`,
|
}/doc`,
|
||||||
|
timeout: 30 * 1000,
|
||||||
json: true
|
json: true
|
||||||
})
|
})
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
@ -464,6 +469,7 @@ describe('DocstoreManager', function() {
|
||||||
url: `${this.settings.apis.docstore.url}/project/${
|
url: `${this.settings.apis.docstore.url}/project/${
|
||||||
this.project_id
|
this.project_id
|
||||||
}/ranges`,
|
}/ranges`,
|
||||||
|
timeout: 30 * 1000,
|
||||||
json: true
|
json: true
|
||||||
})
|
})
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
|
|
Loading…
Reference in a new issue